List<PsiElement> (@NotNull List<Instruction> subGraph, @NotNull List<Instruction> graph) { final List<PsiElement> result = new ArrayList<>(); final List<Instruction> outerGraph = new ArrayList<>(); for (Instruction instruction : graph) { if (!subGraph.contains(instruction)) { outerGraph.add(instruction); } } final Set<PsiElement> subGraphElements = getSubGraphElements(subGraph); for (Instruction instruction : getReadInstructions(outerGraph)) { final PsiElement element = instruction.getElement(); if (element != null) { final PsiReference reference = element.getReference(); if (reference != null) { for (PsiElement resolved : multiResolve(reference)) { if (subGraphElements.contains(resolved)) { result.add(resolved); } } } } } return result; }