'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'

def best_match(self, matches, default=None):

    best_quality = (-1)
    result = default
    for server_item in matches:
        for (client_item, quality) in self:
            if (quality <= best_quality):
                break
            if (self._value_matches(server_item, client_item) and (quality > 0)):
                best_quality = quality
                result = server_item
    return result
