Tip 1: Test isRoot carefully ```cpp bool isRoot() { return !parent || (parent->left != this && parent->right != this); }
**Tip 2: Push down before accessing children** Always pushDown(x) before reading x.left or x.right.
**Tip 3: Push up after modifications** After any rotation or child change, pushUp the modified nodes.
**Tip 4: Handle null pointers** Check for null before accessing children's aggregates.
**Tip 5: Test on small cases** Trace link/cut/access on a 5-node tree by hand before coding.
Time: $O(n)$. Space: $O(n)$.