changed algorithm for tree search function
kdsnfngfngnfjn