def _expand_walk(walks):
    # region
    """

    We expand existing depth-first traversals here.
    A node with multiple predecessors has multiple full length traversals.
    This function splices together existing walks where a node is traversed more than once.

    Parameters
    ----------
    walks: list of DFS edge traversals

    Returns
    -------
    expanded_walks: list of DFS edge traversals expanded with longer paths.
    """
    # endregion
    expanded_walks = []
    walk_starts = {}
    for i, walk in enumerate(walks):
        walk_starts[walk[0]] = i

    for walk in walks:
        path = []
        for i, node in enumerate(walk):
            if node in walk_starts and i > 0:
                if node != walk[0]:
                    p = path
                    p.extend(walks[walk_starts[node]])
                    expanded_walks.append(p)
                    path = []
            path.append(node)
    return expanded_walks