do a better tree transformation