private void rightRotate(RBNode x) {
        RBNode y = x.getLeftChild();
        x.setLeftChild(y.getRightChild());

        if (y.hasRightChild()) {
            y.getRightChild().setParent(x);
        }

        y.setParent(x.getParent());

        if (!x.hasParent()) {
            setRoot(y);
        } else if (x == x.getParent().getRightChild()) {
            x.getParent().setRightChild(y);
        } else {
            x.getParent().setLeftChild(y);
        }

        y.setRightChild(x);
        x.setParent(y);
    }