Optimize subtree_elements by calling find_close only once.