public static void printAllPathToLeafNonRecursive(TreeNode root) {
        if (root == null) return;

        Queue<Object> q = new LinkedList<Object>();
        q.add(root);
        q.add(root.val + "");

        while(!q.isEmpty()){
            TreeNode head = (TreeNode) q.poll();
            String headPath = (String) q.poll();

            if(head.left == null && head.right == null){
                System.out.println(headPath);
                continue;
            }

            if(head.left!=null){
                String leftStr =  headPath + "->" + head.left.val;
                q.add(head.left);
                q.add(leftStr);
            }

            if(head.right!=null){
                String rightStr =  headPath + "->" + head.right.val;
                q.add(head.right);
                q.add(rightStr);
            }
        }
    }