refactoring subtrees