human
I wrote the below code

    def _make_tuple(T, root, _parent):
        'Recursively    compute    the    nested    tuple    representation    of    the\n                                given    rooted    tree.\n\n                                ``_parent``    is    the    parent    node    of    ``root``    in    the    supertree    in\n                                which    ``T``    is    a    subtree,    or    ``None``    if    ``root``    is    the    root    of\n                                the    supertree.    This    argument    is    used    to    determine    which\n                                neighbors    of    ``root``    are    children    and    which    is    the    parent.\n\n                                '
        children = (set(T[root]) - {_parent})
        if (len(children) == 0):
            return ()
        nested = (_make_tuple(T, v, root) for v in children)
        if canonical_form:
            nested = sorted(nested)
        return tuple(nested)
    if (not nx.is_tree(T)):
        raise nx.NotATree('provided    graph    is    not    a    tree')
    if (root not in T):
        raise nx.NodeNotFound('Graph    {}    contains    no    node    {}'.format(T, root))
    return _make_tuple(T, root, None)

What's a good function header?
 ... What is a Python program to determine    which\n                                neighbors    of    ``root``    are    children    and    which    is    the    parent?
assistant
#Here is Python program to determine    which\n                                neighbors    of    ``root``    are    children    and    which    is    the    parent.

@not_implemented_for('directed')
def to_nested_tuple(T, root, canonical_form=False):