public void insert(TreeNode n) {
        numNodes++;
        if (root == null) {
            root = n;
            return;
        }
        TreeNode curNode = root; // root is not null
        String[] nArr = n.getData().split("");
        while (true) {
            if (n.getData().equals(curNode.getData())) {
                System.out.println("This word is already added.");
                return;
            }
            for (int j = 0; j < nArr.length; j++) {
                String[] curNodeArr = curNode.getData().split("");
                if (nArr[j].hashCode() < curNodeArr[j].hashCode()) {
                    if (curNode.getLeft() == null) {
                        curNode.setLeft(n);
                        n.setParent(curNode);
                        return;
                    }
                    curNode = curNode.getLeft();
                    j = 0;
                } else if (nArr[j].hashCode() > curNodeArr[j].hashCode()) {
                    if (curNode.getRight() == null) {
                        curNode.setRight(n);
                        n.setParent(curNode);
                        return;
                    }
                    curNode = curNode.getRight();
                    j = 0;
                }
            }
        }
    }