code: def _patch_dict(diff, base):
      
      for k, v in diff.items():
          if isinstance(v, dict):
              base[k] = _patch_dict(v, base.get(k, {}))
          elif not v:
              base.pop(k, None)
          else:
              base[k] = v
      return base
docs: Patch a dictionary, substituting in changed items from the nested diff.