public void rotateRight(RBNode x) {
    // pushing node x down and to the Right to balance the tree. x's Left child (y)
    // replaces x (since x < y), and y's Right child becomes x's Left child
    // (since it's < x but > y).
    
    RBNode y = x.getLeft();			// get x's Left node, this becomes y
    
    // set x's Right link
    x.setLeft(y.getRight());			// y's Right child becomes x's Left child
    
    // modify parents
    if(y.getRight() != sentinelNode)
      y.getRight().setParent(x);		// sets y's Right Parent to x
    
    if(y != sentinelNode)
      y.setParent(x.getParent());			// set y's Parent to x's Parent
    
    if(x.getParent() != null)				// null=root, could also have used root
    {	// determine which side of its Parent x was on
      if(x == x.getParent().getRight())
        x.getParent().setRight(y);			// set Right Parent to y
      else
        x.getParent().setLeft(y);			// set Left Parent to y
    } else
      setRoot(y);						// at root, set it to y
    
    // link x and y
    y.setRight(x);					// put x on y's Right
    if(x != sentinelNode)				// set y as x's Parent
      x.setParent(y);
  }