implemented swap_subtrees