       # on, there is no lock, so we won't hit this branch.
       lock = if lock_given?, do: remote.converge(deps, lock), else: lock
 
-      deps = deps
-             |> Enum.reject(&remote.remote?(&1))
-             |> Enum.into(%{}, &{&1.app, &1})
+      deps =
+        deps
+        |> Enum.reject(&remote.remote?(&1))
+        |> Enum.into(%{}, &{&1.app, &1})
 
       # In case no lock was given, we will use the local lock
       # which is potentially stale. So remote.deps/2 needs to always


        umbrella? = dep.opts[:from_umbrella]
        deps = reject_non_fulfilled_optional(dep.deps, Enum.map(acc, & &1.app), umbrella?)
        new_breadths = Enum.map(deps, &(&1.app)) ++ current_breadths
        all(deps, acc, current_breadths, new_breadths, callback, rest, lock, env, cache)
    end
  end

    in_upper? = app in upper_breadths

    {acc, match} =
      Enum.map_reduce(list, false, fn other, match ->
        %Mix.Dep{app: other_app, opts: other_opts} = other

        if other_app == app and other.top_level and dep.top_level do
          Mix.shell().error(
            "warning: the dependency #{inspect(dep.app)} is " <>
              "duplicated at the top level, please remove one " <> "of them"
          )
        end

        cond do
          app != other_app ->
            {other, match}

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

          converge?(other, dep) ->
            other =
              other
              |> with_matching_only(dep, in_upper?)
              |> with_matching_req(dep)
              |> merge_manager(dep, in_upper?)

            {other, true}

          true ->
            tag = if in_upper?, do: :overridden, else: :diverged
            {%{other | status: {tag, dep}}, true}
        end
      end)

    if match, do: acc
  end
