title: How to Check if a node is null
body: <p><a href="https://i.stack.imgur.com/mrnbp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mrnbp.png" alt="enter image description here"></a>So I am doing leetcode problem 589. I am just trying to see if i can return the vector when the next node is null. But whenever I run the code I get this error: </p>
  
  <p>Line 933: Char 34: runtime error: reference binding to null pointer of type 'struct Node *' (stl_vector.h)</p>
  
  <p>I don't know how to fix this issue.</p>
  
  <p>this node is null in the tree, since root->children[0]->children[0] has no children. But how to I check if root->children[0]->children[0] has no children?</p>
  
  <pre><code>  int i=1;
    vector&lt;int&gt; result;
      class Solution {
   public:
       vector&lt;int&gt; preorder(Node* root) {
  
      if ((root-&gt;children[0]-&gt;children[0]-&gt;children[0])==NULL)
          return result;
  
       return result;
     }
    };
  </code></pre>