using System.Collections.Generic;
public static void Main()
List<Node> list = new List<Node>();
list.Add(new Node(){begin = 1, end =2});
list.Add(new Node(){begin = 1, end =3});
list.Add(new Node(){begin = 2, end =4});
list.Add(new Node(){begin = 2, end =5});
list.Add(new Node(){begin = 5, end =6});
list.Add(new Node(){begin = 5, end =7});
FindChild(list, 2).Dump();
public static List<int> FindChild(List<Node> list,int id) {
List<int> res = new List<int>();
var child = list.Where(b => b.begin == id).ToList();
foreach (var item in child) {
res.AddRange(FindChild(list,item.end));
public int begin {get;set;}
public int end {get;set;}