###########################################################################
#                                                                         #
# Author: Daniel Mock                                                     #
#                                                                         #
# Purpose: To document progress in learning algorithms & data structures  #
#                                                                         #
# References: This question was generated by leetcode.com. The solution   #
# to the question was generated by Daniel Mock.                           #
#                                                                         #
###########################################################################

# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

#Go back over this solution!!

class Solution:
    def isValidBST(self, root: TreeNode) -> bool:
        if root is None: return True
        stack = []
        node = root
        ref = float('-inf')
        while stack or node:
            while node is not None:
                stack.append(node)
                node = node.left

            node = stack.pop()
            if node.val <= ref:
                return False
            ref = node.val

            node = node.right
        return True
