Mistři v programování na #hovnokod

Python #452

z knihy

def clean_node(node, debug=False):

    if node['sub']:
        sub = []
        num = 1
        for item in node['sub']:
            i = clean_node(item, debug)
            if i:
                sub.append(i)
                num += i['num']
        node['sub'] = sub
        node['num'] = num
    else:
        node['num'] = 1
    if node['deleted']:
        if node['sub']:
            return node
    else:
        return node

    return None

HovnoKod,