     if match, do: acc
   end
 
+  defp with_matching_only(%{opts: other_opts} = other, %{opts: opts} = dep, in_upper?) do
+    if opts[:optional] do
+      other
+    else
+      with_matching_only(other, other_opts, dep, opts, in_upper?)
+    end
+  end
+
   # When in_upper is true
   #
   # When a parent dependency specifies :only that is a subset

  # file, we decided to go with a more explicit approach of
  # asking them to change it to avoid later surprises and
  # headaches.
  defp with_matching_only(%{opts: other_opts} = other, %{opts: opts} = dep, true) do
    case Keyword.fetch(other_opts, :only) do
      {:ok, other_only} ->
        case Keyword.fetch(opts, :only) do

            {other, match}
          in_upper? && other_opts[:override] ->
            {other |> with_matching_only(dep, in_upper?), true}
          converge?(other, dep) ->
            {other |> with_matching_only(dep, in_upper?) |> with_matching_req(dep), true}
          true ->
