def reverse_lookup(dic, val):
    """
    Perform reverse lookup of any key that has the provided value.

    @param dic: Dictionary to perform reverse lookup on.
    @type  dic: C{dict}

    @param val: Value being searched.
    @type  val: an existing value.

    @return: A key such that C{dict[key] == val}.
    @rtype:  Type of the matching key.
    """
    for k, v in dic.items():
        if v == val:
            return k
    raise AssertionError('Value not found in the dictionary.')
