while (x !== tree.root && x.parent.color === NodeColor.Red) {
if (x.parent === x.parent.parent.left) {
if (y.color === NodeColor.Red) {
x.parent.color = NodeColor.Black;
y.color = NodeColor.Black;
x.parent.parent.color = NodeColor.Red;
x = x.parent.parent;
if (x === x.parent.right) {
x = x.parent;