eliminate recursion in chooseSubtree method