title: Need to find the lowest nodes in a tree
body: <p>I have a list of nodes that are part of a tree. I want to filter the list to only the lowest children. For an example tree:</p>
  
  <pre><code>(1)
   |
   +-- (2)
   |    
   +-- (3)
      |
      +-- (4)
      |  
      +-- (5)
           |
           +--(6)
  </code></pre>
  
  <p>If my list is <code>[1,2,5,6]</code>, I would want the results to be <code>[2,6]</code> because they are the lowest descendants. </p>
  
  <p>I have a node method <code>is_descendant()</code> that takes two nodes, and returns <code>True</code> or <code>False</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>1.is_descendant(2) ---&gt; False
  2.is_descendant(1) ---&gt; True
  6.is_descendant(1) ---&gt; True
  </code></pre>
  
  <p>My first idea is to start with the first element in the list and apply the <code>is_descendant()</code> method to every other element. Whenever it returns <code>True</code>, I would remove the other item from the list - since it is a parent node.</p>
  
  <p>Is there a more efficient way to do this? Or will this method work 100% of the time (proof possible?) </p>