private void RotateRight(TextAnchorNode p)
{
// let q be p's left child
var q = p.left;
Debug.Assert(q != null);
Debug.Assert(q.parent == p);
// set q to be the new root
ReplaceNode(p, q);
// set p's left child to be q's right child
p.left = q.right;
if (p.left != null) p.left.parent = p;
// set q's right child to be p
q.right = p;
p.parent = q;
UpdateAugmentedData(p);
UpdateAugmentedData(q);
}