private void rotateRight(Node<T> currentNode, boolean changeRootOfSubtree) {
        if (currentNode.getParent() != null) {
            if (changeRootOfSubtree) {
                Node<T> oldRoot = currentNode;
                Node<T> newRoot = currentNode.getLeftChild();
                newRoot.setParent(oldRoot.getParent());
                oldRoot.getParent().setLeftChild(newRoot);
                Node<T> rCh = newRoot.getRightChild();
                if (rCh != null) {
                    rCh.setParent(oldRoot);
                }
                oldRoot.setLeftChild(rCh);
                oldRoot.setParent(newRoot);
                newRoot.setRightChild(oldRoot);
            } else {
                Node<T> lCh = currentNode.getLeftChild();
                if (currentNode.getParent() != null) {
                    currentNode.getParent().setRightChild(lCh);
                }
                if (lCh != null) {
                    lCh.setParent(currentNode.getParent());
                }
                currentNode.setParent(lCh);
                Node<T> rCh = lCh.getRightChild();
                if (rCh != null) {
                    rCh.setParent(currentNode);
                }
                currentNode.setLeftChild(rCh);
                if (lCh != null) {
                    lCh.setRightChild(currentNode);
                }
            }
        } else {
            Node<T> oldRoot = getNode();
            setNode(currentNode.getLeftChild());
            getNode().setParent(null);
            Node<T> rCh = getNode().getRightChild();
            if (rCh != null) {
                rCh.setParent(oldRoot);
            }
            oldRoot.setLeftChild(rCh);
            getNode().setRightChild(oldRoot);
            oldRoot.setParent(getNode());
        }
    }