def filter_dictionary(dictionary, filter_func):
    """
        returns the first element of `dictionary` where the element's key pass the filter_func.

        filter_func can be either a callable or a value.
        - if callable filtering is checked with `test(element_value)`
        - if value filtering is checked with `element_value == filter_func`

    :param dictionary:
    :param test:
    :return:

    >>> filter_dictionary({'arg': 'test'}, 'test')
    'arg'
    >>> filter_dictionary({}, 'test')

    >>> def is_test(value):
    ...    return value == 'test'
    >>> filter_dictionary({'arg': 'test'}, is_test)
    'arg'
    """
    if not callable(filter_func):
        test_func = lambda x: x == filter_func
    else:
        test_func = filter_func
    for key, value in dictionary.iteritems():
        if test_func(value):
            return key