This script created for db response list array to multidimension tree array.
getTreeArray, it will return tree array
getChildren, it will return children IDs of given node as list array
getParents, it will return parents IDs of given node as list array
Check example php file.