private boolean isIterationComplete(
            TaskModel doWhileTaskModel, Map<String, TaskModel> referenceNameToModel) {
        List<WorkflowTask> workflowTasksInsideDoWhile =
                doWhileTaskModel.getWorkflowTask().getLoopOver();
        int iteration = doWhileTaskModel.getIteration();
        boolean allTasksTerminal = true;
        for (WorkflowTask workflowTaskInsideDoWhile : workflowTasksInsideDoWhile) {
            String taskReferenceName =
                    TaskUtils.appendIteration(
                            workflowTaskInsideDoWhile.getTaskReferenceName(), iteration);
            if (referenceNameToModel.containsKey(taskReferenceName)) {
                TaskModel taskModel = referenceNameToModel.get(taskReferenceName);
                if (!taskModel.getStatus().isTerminal()) {
                    allTasksTerminal = false;
                    break;
                }
            } else {
                allTasksTerminal = false;
                break;
            }
        }

        if (!allTasksTerminal) {
            // Cases where tasks directly inside loop over are not completed.
            // loopOver -> [task1 -> COMPLETED, task2 -> IN_PROGRESS]
            return false;
        }

        // Check all the tasks in referenceNameToModel are completed or not. These are set of tasks
        // which are not directly inside loopOver tasks, but they are under hierarchy
        // loopOver -> [decisionTask -> COMPLETED [ task1 -> COMPLETED, task2 -> IN_PROGRESS]]
        return referenceNameToModel.values().stream()
                .noneMatch(taskModel -> !taskModel.getStatus().isTerminal());
    }
Check if all tasks in the current iteration have reached terminal state.

@param doWhileTaskModel The {@link TaskModel} of DO_WHILE.
@param referenceNameToModel Map of taskReferenceName to {@link TaskModel}.
@return true if all tasks in DO_WHILE.loopOver are in <code>referenceNameToModel</code> and
    reached terminal state.
core/src/main/java/com/netflix/conductor/core/execution/tasks/DoWhile.java