Allows only distinct valued nodes
if ( prev != None and root . data <= prev . data ) : NEW_LINE INDENT return False NEW_LINE DEDENT prev = root NEW_LINE return isBSTUtil ( root . right , prev ) NEW_LINE return True NEW_LINE def isBST ( root ) : NEW_LINE prev = None NEW_LINE return isBSTUtil ( root , prev ) NEW_LINE