def reduce_to_failures(frame):
    if frame.succeeded:
        return []
    l = [frame]
    for (pkg, nodes) in group_attempts(frame.events, fails_filter):
        l2 = []
        for x in nodes:
            if (not isinstance(x, tuple)):
                l2.append(reduce_to_failures(x))
            else:
                l2.append(x)
        l.append((pkg, l2))
    return l
def reduce_to_failures(frame):
    if frame.succeeded:
        return []
    l = [frame]
    for (pkg, nodes) in group_attempts(frame.events, fails_filter):
        l2 = []
        for x in nodes:
            if (not isinstance(x, tuple)):
                l2.append(reduce_to_failures(x))
            else:
                l2.append(x)
        l.append((pkg, l2))
    return l