'Iterates over a generator looking for things that match.'

def _find_all(self, name, attrs, text, limit, generator, **kwargs):

    if ((text is None) and ('string' in kwargs)):
        text = kwargs['string']
        del kwargs['string']
    if isinstance(name, SoupStrainer):
        strainer = name
    else:
        strainer = SoupStrainer(name, attrs, text, **kwargs)
    if ((text is None) and (not limit) and (not attrs) and (not kwargs)):
        if ((name is True) or (name is None)):
            result = (element for element in generator if isinstance(element, Tag))
            return ResultSet(strainer, result)
        elif isinstance(name, basestring):
            result = (element for element in generator if (isinstance(element, Tag) and (element.name == name)))
            return ResultSet(strainer, result)
    results = ResultSet(strainer)
    while True:
        try:
            i = next(generator)
        except StopIteration:
            break
        if i:
            found = strainer.search(i)
            if found:
                results.append(found)
                if (limit and (len(results) >= limit)):
                    break
    return results
