如何用Python删除像嵌套类型的空列表

例如将[a,b,[ [] ,[] ],[ [] ],[c,[d,[] ] ] ]变成[a,b,[c,d] ],将这种像嵌套一样的空列表删掉

>>> def unl(ll):
    result = []
    for i in ll:
        if isinstance(i, list):
            if unl(i):
                result.append(unl(i))
        else:
            if i:
                result.append(i)
    return result

>>> unl(lst)
['a', 'b', ['c', ['d']]]
>>> lst
['a', 'b', [[], []], [[]], ['c', ['d', []]]]