implemented trim BST algo