private static List<IActivity> getEndActivities(IProcessDefinition process) {
   List<IActivity> activities = CollectionUtils.newList();
   for (IActivity activity : process.getActivities()) {
     if (activity.getOutTransitions().isEmpty()) {
       activities.add(activity);
     }
   }
   return activities;
 }
 private static void addActivities(
     Set<TransitionTarget> visited,
     List<TransitionTarget> targets,
     IProcessDefinition process,
     TransitionOptions options,
     boolean forward,
     Stack<TransitionStep> steps) {
   if (forward) {
     addActivity(visited, targets, process.getRootActivity(), options, forward, steps);
   } else {
     for (IActivity activity : getEndActivities(process)) {
       addActivity(visited, targets, activity, options, forward, steps);
     }
   }
 }