def reverse_lookup(d, value):
    """Return first key found with given value.

    Raise ValueError exception if no matches found.
    """
    for k, v in d.iteritems():
        if v == value:
            return k
