private static @Nullable <T> T find(@Nullable List<? extends Pair<IntentionActionDescriptor, ? extends Segment>> markers,
                                      @NotNull Set<? super IntentionActionDescriptor> processed,
                                      @NotNull BiFunction<? super @NotNull IntentionActionDescriptor, ? super @NotNull TextRange, ? extends T> predicate) {
    if (markers != null) {
      for (Pair<IntentionActionDescriptor, ? extends Segment> pair : markers) {
        Segment segment = pair.second;
        TextRange range = segment instanceof RangeMarker ? ((RangeMarker)segment).isValid() ? ((RangeMarker)segment).getTextRange() : null : (TextRange)segment;
        if (range == null) continue;
        IntentionActionDescriptor descriptor = pair.first;
        if (!processed.add(descriptor)) continue;
        T result = predicate.apply(descriptor, range);
        if (result != null) {
          return result;
        }
      }
    }
    return null;
  }
private static @Nullable <T> T find(@Nullable List<? extends Pair<IntentionActionDescriptor, ? extends Segment>> markers,
                                      @NotNull Set<? super IntentionActionDescriptor> processed,
                                      @NotNull BiFunction<? super @NotNull IntentionActionDescriptor, ? super @NotNull TextRange, ? extends T> predicate)