code tree rearranging