title: Create child nodes using recursion
body: <p>I'm trying to create a hierarchy from flat data.  I have the following <code>Node</code> definition:</p>
  
  <pre><code>public class Node {
          public String name;
          public List&lt;Node&gt; children = new ArrayList&lt;&gt;();
      }
  </code></pre>
  
  <p>Given this data: <code>[Person,Manager,Hourly,New]</code>, where the tree should be like:</p>
  
  <pre><code>Person
    |--Manager
         |--Hourly
              |--New
  </code></pre>
  
  <p>I've tried the following:</p>
  
  <pre><code>public void run()
      {
          List&lt;List&lt;String&gt;&gt; objects = new ArrayList&lt;&gt;();
  
          String[] str = {"Person","Manager","Hourly","New"};
          objects.add(Arrays.asList(str)) ;
  
          String[] str2 = {"Person","Manager","Salary"};
          objects.add(Arrays.asList(str2)) ;
  
          String[] str3 = {"Person","Manager","Salary", "New"};
          objects.add(Arrays.asList(str3)) ;
  
          // Create a Node with the sequence
          myNode = new Node();
          createNode(objects.get(0), 0, myNode, myNode);
          LOG.debug(myNode.name);
  }
  </code></pre>
  
  <p>And my <code>createNode</code> method is: </p>
  
  <pre><code>public Node createNode(List&lt;String&gt; seq, Integer start, Node parentNode, Node childNode)
      {
        // do something and return a Node?
      }
  </code></pre>
  
  <p>But conceptually I don't understand how to maintain the structure if Java is return-by-value.  What do I add to <code>createNode</code> so that I can add a Manager->Hourly->New hierarchy as a child to <code>Person</code></p>