recursively make sure that no dictionaries inside node contain empty children lists

def noEmptyNests(node): 
    '''recursively make sure that no dictionaries inside node contain empty children lists '''
    if type(node)==list:
        for i in node:
            noEmptyNests(i)
    if type(node)==dict:
        for i in node.values():
            noEmptyNests(i)
        if node["children"] == []:
            node.pop("children")
    return node