void (final @NotNull Instruction instruction) { final PsiElement element = instruction.getElement(); if (element == null) { // if element is null (fake element, we just process all pending) for (Pair<PsiElement, Instruction> pair : pending) { addEdge(pair.getSecond(), instruction); } pending.clear(); } else { // else we just process all the pending with scope containing in element // reverse order is just an optimization for (int i = pending.size() - 1; i >= 0; i--) { final Pair<PsiElement, Instruction> pair = pending.get(i); final PsiElement scopeWhenToAdd = pair.getFirst(); if (scopeWhenToAdd == null) { continue; } if (!PsiTreeUtil.isAncestor(scopeWhenToAdd, element, false)) { addEdge(pair.getSecond(), instruction); pending.remove(i); } else { break; } } } }