title: How to efficiently build a tree from a flat structure?
body: <p>I have a bunch of objects in a flat structure. These objects have an <code>ID</code> and a <code>ParentID</code> property so they can be arranged in trees. They are in no particular order.
  Each <code>ParentID</code> property does not necessarily matches with an <code>ID</code> in the structure. Therefore their could be several trees emerging from these objects.</p>
  
  <p><strong>How would you process these objects to create the resulting trees ?</strong> </p>
  
  <p>I'm not so far from a solution but I'm sure it is far from optimal...</p>
  
  <p>I need to create these trees to then insert Data into a database, in proper order.</p>
  
  <p>There are no circular references. A Node is a RootNode when ParentID == null or when ParentID can't be found in the other objects</p>