def merge(base_hash, derived_hash, **opts)
      result = base_hash.merge(derived_hash)
      keys_appearing_in_both = base_hash.keys & derived_hash.keys
      keys_appearing_in_both.each do |key|
        if opts[:unset_nil] && derived_hash[key].nil?
          result.delete(key)
        elsif base_hash[key].is_a?(Hash)
          result[key] = merge(base_hash[key], derived_hash[key], **opts)
        elsif should_union?(base_hash, key, opts[:inherit_mode])
          result[key] = base_hash[key] | derived_hash[key]
        elsif opts[:debug]
          warn_on_duplicate_setting(base_hash, derived_hash, key, opts)
        end
      end
      result
    end
def merge(base_hash, derived_hash, **opts)
      result = base_hash.merge(derived_hash)
      keys_appearing_in_both = base_hash.keys & derived_hash.keys
      keys_appearing_in_both.each do |key|
        if opts[:unset_nil] && derived_hash[key].nil?
          result.delete(key)
        elsif base_hash[key].is_a?(Hash)
          result[key] = merge(base_hash[key], derived_hash[key], **opts)
        elsif should_union?(base_hash, key, opts[:inherit_mode])
          result[key] = base_hash[key] | derived_hash[key]
        elsif opts[:debug]
          warn_on_duplicate_setting(base_hash, derived_hash, key, opts)
        end
      end
      result
    end
Return a recursive merge of two hashes. That is, a normal hash merge,
 with the addition that any value that is a hash, and occurs in both
 arguments, will also be merged. And so on.

 rubocop:disable Metrics/AbcSize