internal static IDictionary <TKey, TValue> ToBuilder <TKey, TValue>(this IImmutableDictionary <TKey, TValue> dictionary) where TKey : notnull { return(dictionary switch { ImmutableDictionary <TKey, TValue> d => d.ToBuilder(), ImmutableSortedDictionary <TKey, TValue> d => d.ToBuilder(), ImmutableSegmentedDictionary <TKey, TValue> d => d.ToBuilder(), null => throw new ArgumentNullException(nameof(dictionary)), _ => throw ExceptionUtilities.UnexpectedValue(dictionary), });