@classmethod
def from_dict(cls, d):
    """Creates a query (AND and =) from a dictionary."""
    if not d:
        raise ValueError('Empty dictionary!')
    items = list(d.items())
    key, value = items.pop(0)
    q = cls(key, u'=', value)
    for key, value in items:
        q = q & cls(key, u'=', value)
    return q
