title: sort arraylist into tree recursively
body: <p>I have an arraylist of <code>Object</code>. But I need a tree with the following parameters:</p>
  
  <ol>
  <li>Some Objects are not supposed to have children (non-category objects)</li>
  <li>Category Objects are supposed to have children (which can be additional category objects, or non-category objects)</li>
  <li>Category objects that have no children should be skipped/removed</li>
  </ol>
  
  <p>All objects have a variable for what their parent is. But I don't have a good algorithm that can recursively determine how many children each category object has. All children on the same level will be an <code>ArrayList&lt;Object&gt;</code></p>
  
  <p>I currently have an iterative method that can only go one level deep, and cannot distinguish some versions of scenario 2. I don't think it's code is relevant because it is not recursive.</p>
  
  <p>insight appreciated</p>