def group_attempts(sequence, filter_func=None):
    if (filter_func is None):
        filter_func = (lambda x: True)
    (last, l) = (None, [])
    for x in sequence:
        if (isinstance(x, tuple) and (x[0] == 'inspecting')):
            if l:
                (yield (last, l))
            (last, l) = (x[1], [])
        elif (last is not None):
            if filter_func(x):
                if getattr(x, 'ignored', False):
                    l.extend((y for y in x.events if filter_func(y)))
                else:
                    l.append(x)
    if l:
        (yield (last, l))
def group_attempts(sequence, filter_func=None):
    if (filter_func is None):
        filter_func = (lambda x: True)
    (last, l) = (None, [])
    for x in sequence:
        if (isinstance(x, tuple) and (x[0] == 'inspecting')):
            if l:
                (yield (last, l))
            (last, l) = (x[1], [])
        elif (last is not None):
            if filter_func(x):
                if getattr(x, 'ignored', False):
                    l.extend((y for y in x.events if filter_func(y)))
                else:
                    l.append(x)
    if l:
        (yield (last, l))