code: def filter(self, u):
          
          if not isinstance(u, UniqueIdentity):
              raise ValueError("<u> is not an instance of UniqueIdentity")
  
          filtered = []
  
          for id_ in u.identities:
              username = None
  
              if self.sources and id_.source.lower() not in self.sources:
                  continue
  
              if self._check_username(id_.username):
                  username = id_.username.lower()
  
              if username:
                  fid = UsernameIdentity(id_.id, id_.uuid, username)
                  filtered.append(fid)
  
          return filtered
docs: Filter the valid identities for this matcher.
  
          :param u: unique identity which stores the identities to filter
  
          :returns: a list of identities valid to work with this matcher.
  
          :raises ValueError: when the unique identity is not an instance
              of UniqueIdentity class