code: def merge_settings(settings, new_metadata_settings):
          
          for d in (settings, new_metadata_settings):
              if not isinstance(d, dict):
                  raise TypeError('Both arguments must be dictionaries.')
  
          # Guarantee to not modify original data (`settings.copy()` would not
          # be sufficient, as it's just a shallow copy).
          result_settings = deepcopy(settings)
  
          # previously I will take care of cert stuff
          if 'idp' in new_metadata_settings and 'idp' in result_settings:
              if new_metadata_settings['idp'].get('x509cert', None) and result_settings['idp'].get('x509certMulti', None):
                  del result_settings['idp']['x509certMulti']
              if new_metadata_settings['idp'].get('x509certMulti', None) and result_settings['idp'].get('x509cert', None):
                  del result_settings['idp']['x509cert']
  
          # Merge `new_metadata_settings` into `result_settings`.
          dict_deep_merge(result_settings, new_metadata_settings)
          return result_settings
docs: Will update the settings with the provided new settings data extracted from the IdP metadata
          :param settings: Current settings dict data
          :type settings: string
          :param new_metadata_settings: Settings to be merged (extracted from IdP metadata after parsing)
          :type new_metadata_settings: string
          :returns: merged settings
          :rtype: dict