Collection<Instruction> (final String varName, final Instruction[] instructions, final int instr, final boolean acceptTypeAssertions, final boolean acceptImplicitImports) { final Collection<Instruction> result = new LinkedHashSet<>(); ControlFlowUtil.iteratePrev(instr, instructions, instruction -> { final PsiElement element = instruction.getElement(); final PyImplicitImportNameDefiner implicit = PyUtil.as(element, PyImplicitImportNameDefiner.class); if (instruction instanceof ReadWriteInstruction rwInstruction) { final ReadWriteInstruction.ACCESS access = rwInstruction.getAccess(); if (access.isWriteAccess() || acceptTypeAssertions && access.isAssertTypeAccess()) { final String name = elementName(element); if (Comparing.strEqual(name, varName)) { result.add(rwInstruction); return ControlFlowUtil.Operation.CONTINUE; } } } else if (acceptImplicitImports && implicit != null) { if (!implicit.multiResolveName(varName).isEmpty()) { result.add(instruction); return ControlFlowUtil.Operation.CONTINUE; } } return ControlFlowUtil.Operation.NEXT; }); return result; }