Method for inverting tree pairs