code: def best_match(self, matches, default=None):
          
          if matches:
              best_quality = -1
              result = default
              for client_item, quality in self:
                  for server_item in matches:
                      if quality <= best_quality:
                          break
                      if self._value_matches(server_item, client_item):
                          best_quality = quality
                          result = server_item
              return result
          else:
              return self.best
docs: Returns the best match from a list of possible matches based
          on the quality of the client.  If two items have the same quality,
          the one is returned that comes first.
  
          :param matches: a list of matches to check for
          :param default: the value that is returned if none match