private Stage getStageFromGraphNodes(Stage origStage,
      List<RoleGraphNode> stageGraphNodes) {

    Stage newStage = stageFactory.createNew(origStage.getRequestId(),
        origStage.getLogDir(), origStage.getClusterName(),
        origStage.getClusterId(),
        origStage.getRequestContext(),
        origStage.getCommandParamsStage(), origStage.getHostParamsStage());
    newStage.setSuccessFactors(origStage.getSuccessFactors());
    newStage.setSkippable(origStage.isSkippable());
    newStage.setAutoSkipFailureSupported(origStage.isAutoSkipOnFailureSupported());
    if (commandExecutionType != null) {
      newStage.setCommandExecutionType(commandExecutionType);
    }

    for (RoleGraphNode rgn : stageGraphNodes) {
      for (String host : rgn.getHosts()) {
        newStage.addExecutionCommandWrapper(origStage, host, rgn.getRole());
      }
    }
    return newStage;
  }
Assumes there are no incoming edges.
ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java