   defp get_apps(nil, acc), do: Enum.uniq(acc)
   defp get_apps({:error, _} = err, _acc), do: err
   defp get_apps(%App{} = app, acc) do
-    new_acc = app.applications
-    |> Enum.concat(app.included_applications)
-    |> Enum.reduce([app|acc], fn
-      {:error, _} = err, _acc ->
-        err
-      {a, load_type}, acc ->
-        case Enum.any?(acc, fn %App{name: ^a} -> true; _ -> false end) do
-          true -> acc
-          false ->
+    new_acc =
+      app.applications
+      |> Enum.concat(app.included_applications)
+      |> Enum.reduce([app|acc], fn
+        {:error, _} = err, _acc ->
+          err
+        {a, load_type}, acc ->
+          if Enum.any?(acc, fn %App{name: app} -> a == app end) do
+            acc
+          else
             case App.new(a, load_type) do
               nil ->
                 acc
               %App{} = app ->
                 case get_apps(app, acc) do
-                  {:error, _} = err -> err
-                  children -> Enum.concat(acc, children)
+                  {:error, _} = err ->
+                    err
+                  children ->
+                    Enum.concat(acc, children)
                 end
               {:error, _} = err ->
                 err
             end
-        end
-      a, acc ->
-        case Enum.any?(acc, fn %App{name: ^a} -> true; _ -> false end) do
-          true -> acc
-          false ->
+          end
+        a, acc ->
+          if Enum.any?(acc, fn %App{name: app} -> a == app end) do
+            acc
+          else
             case App.new(a) do
               nil ->
                 acc
               %App{} = app ->
                 case get_apps(app, acc) do
-                  {:error, _} = err -> err
-                  children -> Enum.concat(acc, children)
+                  {:error, _} = err ->
+                    err
+                  children ->
+                    Enum.concat(acc, children)
                 end
               {:error, _} = err ->
                 err
             end
-        end
-    end)
+          end
+      end)
     case new_acc do
-      {:error, _} = err -> err
-      apps -> Enum.uniq(apps)
+      {:error, _} = err ->
+        err
+      apps ->
+        Enum.uniq(apps)
     end
   end
 

        apps = Enum.reverse(apps)
        # Accumulate all unhandled deps, and see if they are present in the list
        # of applications, if so they can be ignored, if not, warn about them
        unhandled = Enum.flat_map(apps, fn %App{unhandled_deps: unhandled} ->
          unhandled
        end) |> MapSet.new
        handled = Enum.flat_map(apps, fn %App{name: a} = app ->
          Enum.concat([a | app.applications], app.included_applications)
        end) |> Enum.uniq |> MapSet.new
        ignore_missing = Application.get_env(:distillery, :no_warn_missing, [])
        missing = MapSet.to_list(MapSet.difference(unhandled, handled))
        missing = case ignore_missing do
                    false  -> missing
                    true   -> []
                    ignore ->
                      Enum.filter(missing, fn
                        a -> not Enum.member?(ignore, a)
                      end)
                  end
        case missing do
          [] -> :ok
          _ ->

  @spec get_release_versions(String.t) :: list(String.t)
  def get_release_versions(output_dir) do
    releases_path = Path.join([output_dir, "releases"])
    if File.exists?(releases_path) do
      releases_path
      |> File.ls!
      |> Enum.filter(&Regex.match?(@valid_version_pattern, &1))
      |> sort_versions
    else
      []
    end
  end

