Clone the tree before transforming it