def is_bst(root):
stack = []<EOL>pre = None<EOL>while root or stack:<EOL><INDENT>while root:<EOL><INDENT>stack.append(root)<EOL>root = root.left<EOL><DEDENT>root = stack.pop()<EOL>if pre and root.val <= pre.val:<EOL><INDENT>return False<EOL><DEDENT>pre = root<EOL>root = root.right<EOL><DEDENT>return True<EOL>
:type root: TreeNode
:rtype: bool