note that the node is an inside grandchild it and its parent are both redso again you see the error message errorparent and child both red fixing this arrangement is slightly more complicated if we try to rotate right with the grandparent node ( at the topas we did in possibility the inside grandchild ( moves across rather than upso the tree is no more balanced than before (try thisthen rotate backwith at the topto restore it different solution is needed the trick when is an inside grandchild is to perform two rotations rather than one the first changes from an inside grandchild to an outside grandchildas shown in figure now the situation is similar to possibility and we can apply the same rotationwith the grandparent at the topas we did before the result is shown in figure we must also recolor the nodes we do this before doing any rotations (this order doesn' really matterbut if we wait until after the rotations to recolor the nodesit' hard to know what to call them the steps are switch the color of ' grandparent ( in this example switch the color of (not its parentx is here rotate with ' parent at the top (not the grandparentthe parent is )in the direction that raises ( left rotation in this example rotate again with ' grandparent ( at the topin the direction that raises ( right rotationthis restores the tree to red-black correctness and also balances it (as much as possibleas with possibility there is an analogous case in which is the right child of rather than the left what about other possibilitiesdo the three post-insertion possibilities we just discussed really cover all situationssupposefor examplethat has sibling sthe other child of this might complicate the rotations necessary to insert but if is blackthere' no problem inserting (that' possibility if is redthen both its children must be black (to avoid violating rule it