Refactored subtree selection