QueryRequestsRunResult (@NotNull ProgressIndicator progress, @NotNull Map<SearchRequestCollector, Processor<? super PsiReference>> collectors) { boolean changed = false; Deque<SearchRequestCollector> queue = new LinkedList<>(collectors.keySet()); while (!queue.isEmpty()) { progress.checkCanceled(); SearchRequestCollector each = queue.removeFirst(); for (QuerySearchRequest request : each.takeQueryRequests()) { progress.checkCanceled(); if (!request.runQuery()) { return QueryRequestsRunResult.STOPPED; } assert !collectors.containsKey(request.collector) || collectors.get(request.collector) == request.processor; collectors.put(request.collector, request.processor); queue.addLast(request.collector); changed = true; } } return changed ? QueryRequestsRunResult.CHANGED : QueryRequestsRunResult.UNCHANGED; }