I have an unusual tree array like this:
[[0, 1], [1, 2], [2, 3], [2, 4], [2, 5], [5, 6],
[4, 6], [3, 6], [0, 7], [7, 6], [8, 9], [9, 6]]
Each element of the array is a pair, which means second one is a follower of the first, e.g.:
[0, 1] - 0 is followed by 1
[1, 2] - 1 is followed by 2
I am trying to extract array like this:
0 1 2 3 6
0 1 2 4 6
0 1 2 5 6
0 7 6
8 9 6
I couldn't code a robust traversal to extract all possible paths like this. How can I do it with Python?