public void add (int val) { binaryTreeNode tmp; boolean done = false; if (null == root) { root = new binaryTreeNode (val); } else { tmp = root; while (!done) { if (val < tmp.getValue ()) { if (null == tmp.getLeftChild ()) { tmp.setLeftChild (new binaryTreeNode (val)); done = true; } else { tmp = tmp.getLeftChild (); } } else // the new value >= value at tmp { if (null == tmp.getRightChild ()) { tmp.setRightChild (new binaryTreeNode (val)); done = true; } else { tmp = tmp.getRightChild (); } } } } }