Check if level of node extracted from queue is required level or not . If it is the required level then check if previous value in that level is less than or equal to value of node .
if currLevel == level : NEW_LINE INDENT if prevVal <= currNode . key : NEW_LINE INDENT prevVal = currNode . key NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT