Thanks for the previous helpful comments, but I am still having a hard time in trying to understand what this condition is checking. Could you please add an inline comment that explains the motivation (both the what and the why) of this stopping test?