def get_trace(edges, start, end, trace=None):
    "Return the trace/path to reach a node in a tree.\n\n    Parameters\n    ----------\n    edges : sequence(2-tuple)\n      The tree given by a sequence of edges (parent, child) tuples. The\n      nodes can be identified by any value and data type that supports\n      the '==' operation.\n    start :\n      Identifier of the start node. Must be present as a value in the parent\n      location of an edge tuple in order to be found.\n    end :\n      Identifier of the target/end node. Must be present as a value in the child\n      location of an edge tuple in order to be found.\n    trace : list\n      Mostly useful for recursive calls, and used internally.\n\n    Returns\n    -------\n    None or list\n      Returns a list with the trace to the target (the starts and the target\n      are not included in the trace, hence if start and end are directly connected\n      an empty list is returned), or None when no trace to the target can be found,\n      or start and end are identical.\n    "
    if (trace is None):
        trace = []
    if (not edges):
        raise ValueError('no edges given')
    for cand in edges:
        (cand_super, cand_sub) = cand
        if (cand_sub in trace):
            continue
        if (trace and (cand_super != trace[(- 1)])):
            continue
        if ((not trace) and (cand_super != start)):
            continue
        if (cand_sub == end):
            return trace
        cand_trace = get_trace(edges, start, end, (trace + [cand_sub]))
        if cand_trace:
            return cand_trace
    return None
Return the trace/path to reach a node in a tree.

Parameters
----------
edges : sequence(2-tuple)
  The tree given by a sequence of edges (parent, child) tuples. The
  nodes can be identified by any value and data type that supports
  the '==' operation.
start :
  Identifier of the start node. Must be present as a value in the parent
  location of an edge tuple in order to be found.
end :
  Identifier of the target/end node. Must be present as a value in the child
  location of an edge tuple in order to be found.
trace : list
  Mostly useful for recursive calls, and used internally.

Returns
-------
None or list
  Returns a list with the trace to the target (the starts and the target
  are not included in the trace, hence if start and end are directly connected
  an empty list is returned), or None when no trace to the target can be found,
  or start and end are identical.
def get_trace(edges, start, end, trace=None):
    "Return the trace/path to reach a node in a tree.\n\n    Parameters\n    ----------\n    edges : sequence(2-tuple)\n      The tree given by a sequence of edges (parent, child) tuples. The\n      nodes can be identified by any value and data type that supports\n      the '==' operation.\n    start :\n      Identifier of the start node. Must be present as a value in the parent\n      location of an edge tuple in order to be found.\n    end :\n      Identifier of the target/end node. Must be present as a value in the child\n      location of an edge tuple in order to be found.\n    trace : list\n      Mostly useful for recursive calls, and used internally.\n\n    Returns\n    -------\n    None or list\n      Returns a list with the trace to the target (the starts and the target\n      are not included in the trace, hence if start and end are directly connected\n      an empty list is returned), or None when no trace to the target can be found,\n      or start and end are identical.\n    "
    if (trace is None):
        trace = []
    if (not edges):
        raise ValueError('no edges given')
    for cand in edges:
        (cand_super, cand_sub) = cand
        if (cand_sub in trace):
            continue
        if (trace and (cand_super != trace[(- 1)])):
            continue
        if ((not trace) and (cand_super != start)):
            continue
        if (cand_sub == end):
            return trace
        cand_trace = get_trace(edges, start, end, (trace + [cand_sub]))
        if cand_trace:
            return cand_trace
    return None