def _metadata_query(self, query_type, any_query_type, kv):
        if kv:  # At least one key-value pair.
            queries = []
            # Iterate pairwise over the arguments.
            it = iter(kv)
            for tag, value in zip(it, it):
                if tag.lower() == u'any':
                    if any_query_type:
                        queries.append(any_query_type(value,
                                                      ITEM_KEYS_WRITABLE,
                                                      query_type))
                    else:
                        raise BPDError(ERROR_UNKNOWN, u'no such tagtype')
                else:
                    _, key = self._tagtype_lookup(tag)
                    queries.append(query_type(key, value))
            return dbcore.query.AndQuery(queries)
        else:  # No key-value pairs.
            return dbcore.query.TrueQuery()
Helper function returns a query object that will find items
dataset/ETHPy150Open beetbox/beets/beetsplug/bpd/__init__.py/Server._metadata_query