title: Creating a java hierarchial treeset from a flat list
body: <p>I have list of Objects T, it has a property of parent where the top objects parent property is null. I want to put all the objects into a TreeSet (or TreeMap). Top level objects will be all the root objects that has no parent (parent is null) and they will have their children under them.</p>
  
  <p>Something like this</p>
  
  <pre><code>              o
             /  |   \
            Ra  Rb   Rc          -- Level Root Objects
           / |   \    | \
          Ca1 Ca2 Cb1 Cc1 Cc2    -- Level of First Children
       /   \
     Ca11   Ca12..............   -- Level of Second Children
  </code></pre>
  
  <p>So I can get Ra and find its children (Ca1, Ca2, Ca11, Ca12....)</p>
  
  <p>Update:
  Sorry may be it wasn't clear, nodes point to parents and if parent is null, they are root nodes. The problem is parents need to know its children. But the relationship is in the opposite direction.</p>
  
  <pre><code>class Node
  {
    private Node parent;
    private String name;
  } 
  </code></pre>