such as the title: it is necessary to traverse all the branch paths of the tree structure from a two-dimensional array with a parent-child structure to form a new array. It is best to use php language to find an algorithm
the original array is
$array = [
["ID"=>"A","SD"=>"B"],
["ID"=>"A","SD"=>"C"],
["ID"=>"A","SD"=>"D"],
["ID"=>"B","SD"=>"E"],
["ID"=>"B","SD"=>"F"],
["ID"=>"E","SD"=>"G"],
["ID"=>"C","SD"=>"H"],
["ID"=>"C","SD"=>"I"]
];
the converted array is:
$targe = [
["B","E","G"],
["B","F"],
["C","H"],
["C","I"],
["D"]
]