public boolean isValidBST(TreeNode root) {
        if (root == null) {
            return true;
        }

        int last = Integer.MIN_VALUE;
        Stack<TraverseWrapper> stack = new Stack<TraverseWrapper>();
        stack.push(new TraverseWrapper(root));
        while (!stack.isEmpty()) {
            TraverseWrapper crt = stack.peek();
            if (crt.status == 0) {
                if (crt.node.left != null) {
                    stack.push(new TraverseWrapper(crt.node.left));
                }
                crt.status = 1;
            }
            else if (crt.status == 1) {
                if (crt.node.val <= last) {
                    return false;
                }
                last = crt.node.val;
                stack.pop();
                if (crt.node.right != null) {
                    stack.push(new TraverseWrapper(crt.node.right));
                }
            }
        }
        return true;
    }