Well, that's a typical semipredicate problem with standard ways to be treated. If you know the kinds of data
produces are limited, use something else as the break out pattern. Otherwise, signal out of band in some other way (exception on end, have your caller test for "has next"), or use the "unique end ref" trick), with the usual implications of each of those.