title: Error: Cannot read field "color" because "u" is null RED BLACK TREE
body: <p>Hello I have an assignment to implement a RBT tree and then as an application insert dictionary in it for more efficient insertion and searching operations.
  When I insert the dictionary file it only reads the first word and 2nd word but doesn't fix up the insertion of the 2nd word and this error shows up <a href="https://i.stack.imgur.com/Dvzd0.png" rel="nofollow noreferrer">enter image description here</a> when I debugged the problem is in the insertfixup method. I think that's where the u is but I'm not sure why even if I don't initialize u with anything it gives me the same error so I tried to initialize it with TNULL and it still the same I hope my problem is clear</p>
  <pre><code>private void insertFixUp(Node x) {
  Node u = TNULL;
      while (x.parent.color == 1){
          if(x.parent == x.parent.parent.right){
              u=x.parent.parent.left;
          if (u.color == 1){
              u.color =0;
              x.parent.color = 0;
              x.parent.parent.color = 1;
              x = x.parent.parent;
          }
          else {
              if(x == x.parent.left) {
              x = x.parent;
              rightRotate(x);
          }
              x.parent.color=0;
              x.parent.parent.color=1;
              leftRotate(x.parent.parent);
          }
      } else {
              u = x.parent.parent.right;
  
              if (u.color == 1){
                  u.color =0;
                  x.parent.color = 0;
                  x.parent.parent.color = 1;
                  x = x.parent.parent;
              }
              else {
                  if(x == x.parent.right) {
                      x = x.parent;
                      leftRotate(x);
                  }
                  x.parent.color=0;
                  x.parent.parent.color=1;
                  leftRotate(x.parent.parent);
              }
          }
          if(x == root){
              break;
          }
    }
      root.color=0;
  
  }
  </code></pre>