private ArrayList<Integer> traverseNonRecursive(TraversalType traversalType) {
        ArrayList<Integer> result = new ArrayList<Integer>();
        LinkedList<BinaryTree> stack = new LinkedList<BinaryTree>();
        stack.push(this);
        BinaryTree previous = null;

        while(!stack.isEmpty())
        {
            BinaryTree current = stack.peek();
            if (current==null)
                stack.pop();
            else if (current.left==null && current.right==null)
            {
                //Case 1
                //at leaf node
                //always - visit leaf
                result.add(current.data);
                stack.pop();
            }
            else if (previous == current.right)
            {
                //Case 2
                //returned up after right node
                if (traversalType==TraversalType.POSTORDER)
                    result.add(current.data);
                stack.pop();
            }
            else if (previous == current.left)
            {
                //Case 3
                //returned up from the left node
                if (traversalType==TraversalType.INORDER)
                    result.add(current.data);
                stack.push(current.right);
            }
            else {
                //Case 4
                //everything else - let's go to the left node down
                if (traversalType==TraversalType.PREORDER)
                    result.add(current.data);
                stack.push(current.left);
            }
            previous = current;
        }

        return result;
    }