title: Cannot read property '$$nextSibling' of null
body: <p>I keep getting this error in my program when I destroy my own scopes. I tracked it down to this while loop within angular:</p>
  
  <pre><code>if (!(next = (current.$$childHead || (current !== target &amp;&amp; current.$$nextSibling)))) {
      while(current !== target &amp;&amp; !(next = current.$$nextSibling)) {
          current = current.$parent;
      }
  }
  </code></pre>
  
  <p>I've also managed to replicate it in a jsFiddle: <a href="http://jsfiddle.net/kEyqz/1/" rel="noreferrer">http://jsfiddle.net/kEyqz/1/</a></p>
  
  <p>It's pretty easy to set up, on an element I wire up a click event and then $broadcast that it was clicked followed by an $apply.</p>
  
  <p>In a separate directive (with a child scope) I listen in on that event, and if I see it, I destroy the child scope. Doing so produces the error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property '$$nextSibling' of null 
  </code></pre>
  
  <p>This is just a small example of what I'm trying to accomplish in my code.</p>
  
  <p>Console logging right before current = current.$parent results in the scope having no $parent (it is set to null).</p>
  
  <p>I can add the lines:</p>
  
  <pre><code>if(!current){
      break;
  }
  </code></pre>
  
  <p>After the current = current.$parent, but i'd have to maintain it if I switch angular versions (not ideal)</p>