Given a binary tree, write a method to perform the inorder traversal **iteratively**. Append the data of each node visited to an ArrayList. Return an empty Arraylist in the case of an empty tree.

Example: 1 / \ 2 3 ==> 4251637 / \ / \ 4 5 6 7

Need a **hand?** Try out these hints, one at a time.

Inorder traversal :

`Left, Data, Right`

Use a stack based iterative approach

1.Create a `Stack`

for storing the tree's nodes.

2. Start nested loops to traverse through the entire tree and its subtrees.

3. Run the outer loop infinitely and traverse the inner loop till the root becomes null.

4. Within the inner loop, push a node onto the `stack`

and change it to its left node.

5. Outside the inner loop, start popping the nodes from the Stack. Insert the data of the node in an `ArrayList`

that needs to be returned. Move to the right child.

6. If the `Stack`

becomes empty, `break`

out of the outer loop.

public ArrayList<Integer> inorderItr(TreeNode root) { }

**C**

**Java**

**Python**