def _consume_until_marker(it, marker):
    """ Consume data from the iterator, until marker is found (compared using
    operator `is`).
    Returns tuple of number of elements consumed before the marker and bool
    indicating whether the marker was found (False means the iterator was
    exhausted. """
    i = -1
    for i, v in enumerate(it):
        if v is marker:
            return (i, True)
    return (i + 1, False)