def map(function, dictionary, recursive=True):
    """

    Apply function to every value of dictionary and return a dictionary of the 
    results. 
    """
    result = {}
    if function == None:
        function = lambda x: x
    for key in dictionary:
        value = dictionary[key]
        if recursive and type(value) == dict:
            value = map(function, value)
        key, value = function(key, value)
        result[key] = value
    return result
