for node in graph.get(start, []):
    if node not in path:
        for new_path in find_all_paths(graph, node, end, path):
            yield new_path
for n in graph:
    for e in nodes:
        if n != e:
            for path in find_all_paths(graph, n, e):
                if path:
                    pass
Рекурсивный поиск комбинаций родительских и дочерних элементов и построение дерева в python и XML.