private Pair.NonNull<T,V> findNextClassInQueue(@NotNull HashSetQueue.PositionalIterator.IteratorPosition<? extends T> position) {
    // find the first class suitable for analyzing inheritors of (not anonymous and not final and retrievable from PsiAnchor) and not already processed or being processed (by other thread)
    // couldn't call iterator.next() until class is processed, so use position.peek()/position.next() which don't advance iterator
    while (position != null) {
      ProgressManager.checkCanceled();
      T anchor = position.peek();
      if (!classesProcessed.contains(anchor) && !classesBeingProcessed.contains(anchor)) {
        V value = myAnchorToValueConvertor.apply(anchor);
        boolean isAccepted = value != null && myApplicableForGenerationFilter.test(value);
        if (isAccepted) {
          return Pair.createNonNull(anchor, value);
        }
        classesProcessed.add(anchor);
      }
      // the candidate is already being processed in the other thread, try the next one (not advancing iterator!)
      position = position.next();
    }
    return null;
  }
private Pair.NonNull<T,V> findNextClassInQueue(@NotNull HashSetQueue.PositionalIterator.IteratorPosition<? extends T> position)