I wrote this method to recursively insert a new node at the proper position in a BST. Is it good enough? Can it be improved? It went through a couple of revisions and I still am not very confident in this version. Making the new node root when no nodes are present is taken care of in a separate wrapper function.
public void insertNode(Node<Integer> currentParent, Node<Integer> newNode) {
if (newNode.getNodeData() < currentParent.getNodeData()) {
if(currentParent.getLeftChild() == null)
currentParent.setLeftChild(newNode);
else
insertNode(currentParent.getLeftChild(), newNode);
} else {
if(currentParent.getRightChild() == null)
currentParent.setRightChild(newNode);
else
insertNode(currentParent.getRightChild(), newNode);
}
}