Return a recursive structure describing given tree

def set_from_tree(root:str, graph:dict) -> frozenset:
    """Return a recursive structure describing given tree"""
    Node = namedtuple('Node', 'id succs')
    succs = graph[root]
    if succs:
        return (len(succs), sorted(tuple(set_from_tree(succ, graph) for succ in succs)))
    else:
        return 0, ()