search is changed to return a subtree instead of val