Question: Lets say we have a **Binary Tree** 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 :

```
  public List<T> fromTreeToList(){
   // use elementsToList to create the list
    }
public (what is the optional) elementsToList(Node node){
   // use this method to recursion
        List<T> example = new ArrayList<>();
        if (node != null){
            example.add(node.val) ;
            example.add(elementsToList(node.left));
            example.add(elementsToList(node.right)) ;
       }else System.out.println("Empty Tree");
}

```

Answer: 
We can use a recursive function for tree traversal and keep adding the elements to the list.
Assuming that Node.val is of type int

```
public static void main(String[] args) {
        //assuming that we already have tree with root treeRoot
        List<Integer> list = new ArrayList<>();
        treeItemsToList(treeRoot, list); 
        //print the list
    }

public void treeItemsToList(Node node, List<Integer> list ){
        if(node == null){
            return;
        }
        treeItemsToList(node.left, list);
        list.add(node.val);
        treeItemsToList(node.right, list);
    }

```
If you provided your code, my answer would be more precise, but this is my implementation of your method using `Preorder Traversal`, basically you add `Node`, if you go down the `Tree` otherwise you navigate to the most left everytime and then check the right side of the `subtree`.

```
public List<Node> fromTreeToList(){
    return elementsToList(root);
}

public List<Node> elementsToList(Node node) {
    List<Node> nodes = new ArrayList<>();
    Node current = node;
    Node rootParent = node.getParent();
    Node previous = null;
    while (current != rootParent) {
        if (previous == current.getParent()) { // going down the tree
            nodes.add(current);
            previous = current;
            if (current.getLeft() != null) {
                current = current.getLeft();
            } else {
                if (current.getRight() != null) {
                    current = current.getRight();
                } else {
                    current = current.getParent();
                }
            }
        } else if (previous.equals(current.getLeft())) { // going up the left subtree
            previous = current;
            if (current.getRight() != null) {
                current = current.getRight();
            } else {
                current = current.getParent();
            }
        } else { // going up the right subtree
            previous = current;
            current = current.getParent();
        }
    }
    return nodes;
}

```