Rearrange tree