public static List<Integer> inorderTraversalnonrecursive (TreeNode root) {
        ArrayList<Integer> arrlst = new ArrayList<Integer>();
        if (root == null) return arrlst;
        Stack<TreeNode> stk = new Stack<TreeNode>();
        while (stk.isEmpty() == false || root != null) {
            if (root != null) {
                stk.push(root);
                root = root.left;
            }
            else {
                root = stk.pop();
                arrlst.add(root.val);
                root = root.right;
            }
        }
        return arrlst;
    }