unrooted_paths = []
for subtree in tree.children:
    useable, unueseable = paths(subtree)
for path in useable:
    unrooted_paths.append(path)
rooted_paths.append([root] + path)
for path in unuseable:
    unrooted_paths.append(path)
return rooted_paths, unrooted_paths

def the_function_you_use_in_the_end(tree):
    a, b = paths(tree)
return a + b
Перечисление всех путей в дереве