title: Get all elements from a Binary Tree to a List - JAVA
body: <p>Lets say we have a <strong>Binary Tree</strong> and we want to iterate through it and get all Elements (Node.value) and create a List with them.
  I thought directing to the problem this way :</p>
  <pre><code>  public List&lt;T&gt; fromTreeToList(){
     // use elementsToList to create the list
      }
  public (what is the optional) elementsToList(Node node){
     // use this method to recursion
          List&lt;T&gt; example = new ArrayList&lt;&gt;();
          if (node != null){
              example.add(node.val) ;
              example.add(elementsToList(node.left));
              example.add(elementsToList(node.right)) ;
         }else System.out.println(&quot;Empty Tree&quot;);
  }
  </code></pre>