 
   """
   @spec union(t(val1), t(val2)) :: t(val1 | val2) when val1: value, val2: value
+  def union(%MapSet{map: map1, version: version} = map_set, %MapSet{map: map2, version: version}) do
+    %{map_set | map: Map.merge(map1, map2)}
+  end
   def union(%MapSet{map: map1}, %MapSet{map: map2}) do
-    %MapSet{map: Map.merge(map1, map2)}
+    new_from_list(Map.keys(map1) ++ Map.keys(map2), [])
   end
 
   defp order_by_size(map1, map2) when map_size(map1) > map_size(map2), do: {map2, map1}

  # If the second set is less than half the size of the first set, it's fastest
  # to simply iterate through each item in the second set, deleting them from
  # the first set.
  def difference(%MapSet{map: map1}, %MapSet{map: map2}) do
    %MapSet{map: Map.drop(map1, Map.keys(map2))}
  end

  defp filter_not_in(keys, map2, acc \\ [])

    if map_size(map1) <= map_size(map2) do
      map1
      |> Map.keys
      |> map_subset?(map2)
    else
      false
    end
  end

  defp map_subset?([], _), do: true
  defp map_subset?([key | rest], map2) do
    if Map.has_key?(map2, key) do
      map_subset?(rest, map2)
    else
      false
    end
