You have processed subtrees separately in previous sections. Sometimes you need to combine results from all children into one structure for the parent. Naive merging takes time in the worst case. A chain tree makes you merge sets of size , , , up to , giving quadratic time.
I'll show you small-to-large merging, a trick that guarantees total operations across the entire tree. This technique is called DSU on tree or Sack, and it is effective for subtree queries.