code: def map_leafs(func, mapping):
      
  
      def _inner(mapping, path=None):
          if path is None:
              path = []
  
          for key, val in mapping.items():
              if isinstance(val, collections.Mapping):
                  _inner(val, path + [key])
              else:
                  mapping[key] = func(val, path=path+[key])
  
          return mapping
  
      return _inner(copy.deepcopy(mapping))
docs: Map a function to the leafs of a mapping.