private void balanceIfNecessary(TreeNode node) {
			if (node.getBalanceFactor() == 2) {
				if (node.hasRightChild() && node.rightChild.getBalanceFactor() == -2) {
					node.rotateRightLeft();
				} else {
					node.rotateLeft();
				}
			} else if (node.getBalanceFactor() == -2) {
				if (node.hasLeftChild() && node.leftChild.getBalanceFactor() == 2) {
					node.rotateLeftRight();
				} else {
					node.rotateRight();
				}
			}
			
			if (node.parent == null) {
				this.root = node;
			} else {
				balanceIfNecessary(node.parent);
			}
		}