code: def filter(self, iterable):  # noqa A001
          
  
          if CSSMatch.is_tag(iterable):
              return CSSMatch(self.selectors, iterable, self.namespaces, self.flags).filter()
          else:
              return [node for node in iterable if not CSSMatch.is_navigable_string(node) and self.match(node)]
docs: Filter.
  
          `CSSMatch` can cache certain searches for tags of the same document,
          so if we are given a tag, all tags are from the same document,
          and we can take advantage of the optimization.
  
          Any other kind of iterable could have tags from different documents or detached tags,
          so for those, we use a new `CSSMatch` for each item in the iterable.