reorganising the tree