def run(arg):
    """
    Repeatedly advance a single iterator until it returns a value.
    Primarily useful in testing nested generators.
    """
    try:
        while 1: next(arg)
    except StopIteration as si:
        return si.value