Added functions to find tree structure.