use swap for subtree replacement