private TaskWrapper[] getTasksArray(Predicate<Task> predicate) {
      if (null == predicate) {
        return tasks.toArray(new TaskWrapper[tasks.size()]);
      }

      List<TaskWrapper> interim = new ArrayList<>();

      for (TaskWrapper wrapper : tasks) {
        Collection<Task> filtered = Collections2.filter(wrapper.getTasks(), predicate);

        if (CollectionUtils.isNotEmpty(filtered)) {
          interim.add(wrapper);
        }
      }

      return interim.toArray(new TaskWrapper[interim.size()]);
    }
Get the task wrappers for this proxy.  Server-side tasks cannot be executed more than
one time per grouping.
@param predicate the predicate to determine if a server-side task has already been added to a wrapper.
@return the wrappers for a stage
ambari-server/src/main/java/org/apache/ambari/server/stack/upgrade/ColocatedGrouping.java