def _pre_gen(it, first):
    """A generator that returns first first if it exists."""
    if first:
        yield first
    while it:
        try:
            yield next(it)
        except StopIteration:
            return
