Does that help You may first create a map using the task name as the key and the relevant Task as the value. Ignore the duplicate Tasks merely by using a mergeFunction. Then get all the distinct tasks as a Set view.
Set<Task> distinctTasks = tasks.stream().collect(Collectors.collectingAndThen(
(a, b) -> a), m -> new HashSet<>(m.values())));
Java Stream filter - how can i filter data without wrapping the filter code in 'if' condition for checking null on the f