code: def walk_json(d, func):
      
      if isinstance(d, Mapping):
          return OrderedDict((k, walk_json(v, func)) for k, v in d.items())
      elif isinstance(d, list):
          return [walk_json(v, func) for v in d]
      else:
          return func(d)
docs: Walk over a parsed JSON nested structure `d`, apply `func` to each leaf element and replace it with result