class RelocationUtil {

    public static List<String> buildTasksFromNodesAndJobsFilter(Map<String, Node> nodesById, Set<String> jobIds,
                                                                ReadOnlyJobOperations jobOperations) {
        Map<String, Task> tasksById = buildTaskByIdMap(jobOperations);
        Set<String> taskIdsOnNodes = buildTasksToInstanceMap(nodesById, tasksById).keySet();
        return taskIdsOnNodes.stream().filter(taskId -> {
            if (tasksById.containsKey(taskId)) {
                Task task = tasksById.get(taskId);
                return jobIds.contains(task.getJobId());
            }
            return false;
        }).collect(Collectors.toList());
    }

}