Find sequences child-father in a table

Hi,

I need to find the sequences child-father in this table starting with an input id. For example 1-3-9-11-18 or 2-5-6-15-20. I tried using query in forEach loop but without success. Do you have any suggestions about it? 

id idFather
1 3
2 5
3 9
5 6
6 15
9 11
11 18
15 20

  Discussion posts and replies are publicly visible

Parents Reply Children