code: List<TaskHandle> addToQueue(final Collection<Task> tasks) {
      List<TaskHandle> handles = new ArrayList<>();
      Map<String, List<TaskOptions>> queueNameToTaskOptions = new HashMap<>();
      for (Task task : tasks) {
        logger.finest("Enqueueing: " + task);
        String queueName = task.getQueueSettings().getOnQueue();
        TaskOptions taskOptions = toTaskOptions(task);
        List<TaskOptions> taskOptionsList = queueNameToTaskOptions.get(queueName);
        if (taskOptionsList == null) {
          taskOptionsList = new ArrayList<>();
          queueNameToTaskOptions.put(queueName, taskOptionsList);
        }
        taskOptionsList.add(taskOptions);
      }
      for (Map.Entry<String, List<TaskOptions>> entry : queueNameToTaskOptions.entrySet()) {
        Queue queue = getQueue(entry.getKey());
        handles.addAll(addToQueue(queue, entry.getValue()));
      }
      return handles;
    }
docs: VisibleForTesting