def find_key(value, dictionary, default=None):
    """
    Find the given value in the given dictionary and returns its key.
    If value is not found - return default value (None or given).
    If many elements can be found - return one of them arbitrarily (the first one found)::

        >>> find_key('d', {'a': 'b', 'c': 'd'})
        'c'

        >>> find_key('c', {'a': 'b', 'c': 'd'}, default=-1)
        -1

    :param value: value in dictionary, which for is searching a key
    :param dictionary: dictionary to search in
    :param default: value returned if value is not in dictionary (default None)
    :return: key which value in dictionary is assigned to
    """

    for key, item_value in dictionary.items():
        if value == item_value:
            return key

    return default