def revdict_lookup(dict, lookup_val):
    """(revdict_lookup):
        Performs a reverse dictionary lookup. Careful: only returns first match, but there may be others.
    """
    key = (key for key, value in dict.items() if value == lookup_val).next()
    return key
