def _inline_single_path(path, all_paths):
    """Inline a path.

    * path must be in primitive recursive form:
    [(src, n1, e_id1), (n1, dest, None)]
    * all_paths must contain all paths in the graph that
    start at node n1, in aggregated and inlined form.

    If there is only one node from n1 to dest, the inlining returns
    an inlined representation of the path:
    [(src, n1, e_id1), edges of the path from n1 to dest]
    otherwise, path is returned unchanged (since inlining would generate
    multiple paths.
    """
    if len(path) == 1:
        return path
    else:
        e0, (src, dest, e_id) = path
        assert e_id is None
        sub_paths = all_paths[src][dest]
        if len(sub_paths) == 1:
            return [e0] + sub_paths[0]
        else:
            return path