title: Create all possible subtree of a tree in java
body: <p>I have a generic tree and I want to generate all possible subtrees from it.
  Example (the values in the nodes are random):</p>
  <pre><code>          0 
          / | \ 
         1  2  4
            |  
            3          
  </code></pre>
  <p>The possible output will be:</p>
  <pre><code>(0)
  (0,1)(0,2)(0,4)(0,2,3)
  (0,1,2) (0,2,4) (0,1,2,3) (0,1,2,4) (0,2,3,4) 
  (0,1,2,3,4)
  
  </code></pre>
  <p>I add that I pass a tree object that contains a list of nodes and edges, and then print with graphviz. Example :</p>
  <pre><code>List&lt;Node&gt; nodes = new ArrayList&lt;&gt;(); // [0,1,2,3,4]
  List&lt;Edge&gt; edges = new ArrayList&lt;&gt;(); // [(0,null), (0,1), (0,2), (2,3), (0,4)]
  
  Tree tree = new Tree(nodes,edges); 
  // this is an example of a tree that I pass as a parameter
  </code></pre>
  <p>I'm trying to do a recursive method, but the edges I pass can be random, as can the nodes. I only know the root node, which is in the first edge [(0, null)]</p>
  <p>thanks in advance for your time!</p>