code: def scan_nestdict(d, key):
      
      if isinstance(d, (list, tuple)):
          for item in d:
              res = scan_nestdict(item, key)
              if res is not None:
                  return res
          return None
  
      if not isinstance(d, collections.Mapping):
          return None
  
      if key in d:
          return d[key]
      else:
          for v in d.values():
              res = scan_nestdict(v, key)
              if res is not None:
                  return res
          return None
docs: Scan a nested dict d, and return the first value associated to the given key.
      Returns None if key is not found.
  
      >>> d = {0: 1, 1: {"hello": {"world": {None: [1,2,3]}}}, "foo": [{"bar": 1}, {"color": "red"}]}
      >>> assert scan_nestdict(d, 1) == {"hello": {"world": {None: [1,2,3]}}}
      >>> assert scan_nestdict(d, "hello") == {"world": {None: [1,2,3]}}
      >>> assert scan_nestdict(d, "world") == {None: [1,2,3]}
      >>> assert scan_nestdict(d, None) == [1,2,3]
      >>> assert scan_nestdict(d, "color") == "red"