private void addSkippedStages(Map<String, List<ExecuteStage>> skippedStages, List<ExecuteStage> stagesJustAdded) {
    for (ExecuteStage stage : stagesJustAdded) {
      if (skippedStages.containsKey(stage.service)) {
        List<ExecuteStage> stagesToAdd = skippedStages.remove(stage.service);
        addGroupingStages(stagesToAdd, stage.service);
        addSkippedStages(skippedStages, stagesToAdd);
      }
    }
  }
Adds the skipped stages if the stage they are supposed to come after has been added.
ambari-server/src/main/java/org/apache/ambari/server/stack/upgrade/ClusterGrouping.java