title: BST removing node with 2 children not deleting predecessor
body: <p>I am working on removing nodes from a BST. It currently works for all cases in which there is no children, or one child. When I go to remove a node with 2 children, the node gets removed, but the predecessor value does not get changed to null as I feel the code accounts for that, but nothing changes.</p>
  
  <pre><code>   public Node(String w, Node p, Node l, Node r) {
           //value = v;
           word = w;
           parent = p;
           left = l;
           right = r;
        }
     public void remove(String target) {
        if (root == null) {
           return;
        }
        if (root.word.compareTo(target) == 0)
        {
           removeRoot(target);
        }
        else {
           removeNonRoot(target);
        }
     }
     private void removeNonRoot(String target) {
  
        Node cur = root;
        Node parent = null;
  
        while (cur != null) {
           if (cur.word.compareTo(target) == 0) {
              break;
           }
           if (target.compareTo(cur.word) &lt; 0) {
              if (cur.left != null) {
                 parent = cur;
                 cur = cur.left;
              }
           }
           else if (target.compareTo(cur.word) &gt; 0) {
              if (cur.right != null) {
                 parent = cur;
                 cur = cur.right;
              }
           }
        }
       if (cur.left == null &amp;&amp; cur.right == null)
        {
           if (parent.left != null &amp;&amp; parent.left.word.compareTo(target) == 0) {
              parent.left = null;
           }
           else if (parent.right != null &amp;&amp; parent.right.word.compareTo(target) == 0)
           {  
              parent.right = null;
           }
        }
        else if (cur.left == null &amp;&amp; cur.right != null) {
           if (parent.right != null &amp;&amp; parent.right.word.compareTo(target) == 0) {
              parent.right = cur.right;
           }
           else if (parent.left != null &amp;&amp; parent.left.word.compareTo(target) == 0) {
              parent.left = cur.right;
           }
        }
        else {
           Node temp = findPredecessor(target, parent);
           cur.word = temp.word;
        }
     }
  private void removeRoot(String target) {
     // only root
        if (root.left == null &amp;&amp; root.right == null)
        {
           root = null;
           return;
        }
        // right child
        else if (root.left == null)
        {
           root = root.right;
           return;
        }
        // left child
        else if (root.right == null)
        {
           root = root.left;
        }
        // 2 children
        else
        {
           Node temp = findPredecessor(target, root);
           root.word = temp.word;
           return;
        }
     }
  
  private Node findPredecessor(String s, Node start) {
        Node parent = start;
        Node child = start.left;
  
        if (child == null) {
           return parent;
        }
        else if (child != null) {
           while (child.right != null) {
              child = child.right;
           }
           Node temp = child;
           child.right = null;
           return temp;
        }
        else {
           return null;
        }
  }
  </code></pre>
  
  <p>If I had a bst with characters inserted in this order: e -> f -> c -> a -> d the result from trying to remove c would return d where c was, but also the right subtree of d, would be d.</p>
  
  <p>Which would lead me to believe the issue is in my predecessor method where I call child.right = null. I don't think the value actually get's assigned, but am unsure why.
  Drawing of removal result:
  <img src="https://i.stack.imgur.com/VpITc.png" alt=""></p>