DFAFlowInfo (@NotNull List<DefinitionMap> definitionMaps, @NotNull Instruction instruction, int descriptorId, @NotNull Predicate<? super Instruction> predicate) { Map<Pair<Instruction, Integer>, Collection<Pair<Instruction, Integer>>> interesting = new LinkedHashMap<>(); LinkedList<Pair<Instruction, Integer>> queue = new LinkedList<>(); queue.add(Pair.create(instruction, descriptorId)); Map<PsiElement, Collection<ReadWriteVariableInstruction>> scopeCache = new HashMap<>(); while (!queue.isEmpty()) { Pair<Instruction, Integer> pair = queue.removeFirst(); if (!interesting.containsKey(pair)) { Set<Pair<Instruction, Integer>> dependencies = findDependencies(definitionMaps, pair.first, pair.second, scopeCache); interesting.put(pair, dependencies); dependencies.forEach(queue::addLast); } } Set<Instruction> interestingInstructions = interesting.keySet().stream() .map(it -> it.getFirst()) .filter(predicate).collect(Collectors.toSet()); Set<Instruction> acyclicInstructions = findNodesOutsideCycles(mapGraph(interesting)).stream() .map(it -> it.getFirst()) .filter(predicate) .collect(Collectors.toSet()); Set<Integer> interestingDescriptors = interesting.keySet().stream() .map(it -> it.getSecond()) .collect(Collectors.toSet()); return new DFAFlowInfo(interestingInstructions, acyclicInstructions, interestingDescriptors); }