private void addSkippedGroup(List<Grouping> groups, Map<String, List<Grouping>> skippedGroups, Grouping groupJustAdded) throws AmbariException {
    if (skippedGroups.containsKey(groupJustAdded.name)) {
      List<Grouping> groupsToAdd = skippedGroups.remove(groupJustAdded.name);
      for (Grouping group : groupsToAdd) {
        boolean added = addGrouping(groups, group);
        if (added) {
          addSkippedGroup(groups, skippedGroups, group);
        } else {
          throw new AmbariException("Failed to add group " + group.name);
        }
      }
    }
  }
Adds any groups which have been previously skipped if the group which they should come
after have been added.
ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java