public void insertValue(int value) { if (rootNode == null) { rootNode = new IntNode(value); } else { IntNode currentNode = rootNode; while (currentNode.getValue() != value) { if (value > currentNode.getValue()) { // Right child path if (currentNode.getRightChild() == null) { currentNode.setRightChild(new IntNode(value)); } currentNode = currentNode.getRightChild(); } else { // Left child path if (currentNode.getLeftChild() == null) { currentNode.setLeftChild(new IntNode(value)); } currentNode = currentNode.getLeftChild(); } } } }