private static List<TodoItem> applyFilterAndRemoveDuplicatesAndSort(TodoItem @NotNull [] items, @Nullable TodoFilter filter) {
    record ByRange(@NotNull TextRange range, @NotNull TodoItem item) {
      @Override
      public boolean equals(Object obj) {
        return obj instanceof ByRange br && range.equals(br.range);
      }
      @Override
      public int hashCode() {
        return range.hashCode();
      }
    }
    return Arrays.stream(items)
      .filter(next -> filter == null || (next.getPattern() != null && filter.contains(next.getPattern())))
      .map(p->new ByRange(p.getTextRange(), p))
      .distinct()
      .map(br -> br.item())
      .sorted(TodoItem.BY_START_OFFSET)
      .toList();
  }
private static List<TodoItem> applyFilterAndRemoveDuplicatesAndSort(TodoItem @NotNull [] items, @Nullable TodoFilter filter)