Binary Search Tree recursive add
<p>I'm trying to make a recursive add for my BST. The public add method takes an int argument, the private method takes the same int and a Node. This is the code I have so far</p>

<pre><code> public void add(int i) {

    add(i, root);

}

private void add(int i, Node n) {
    if (root==null){
        root=new Node(i);
    }

    if (i &lt; n.element) {
        if (n.left != null) {
            add(i, n.left);
        } else {
            n.left = new Node(i);
        }
    } else if (i &gt; n.element) {
        if (n.right != null) {
            add(i, n.right);
        } else {
            n.right = new Node(i);
        }
    }
}
</code></pre>

<p>I constanly keep getting null pointers, tried debugging as well but there's something flawed in my logic that I can't see.</p>