boolean (@NotNull PyReferenceExpression node, @NotNull ScopeOwner owner) { final String nodeName = node.getReferencedName(); final Scope scope = ControlFlowCache.getScope(owner); final ControlFlow flow = ControlFlowCache.getControlFlow(owner); final Instruction[] instructions = flow.getInstructions(); final int num = ControlFlowUtil.findInstructionNumberByElement(instructions, node); if (num < 0) { return true; } final Ref<Boolean> first = Ref.create(true); ControlFlowUtil.iteratePrev(num, instructions, instruction -> { if (instruction instanceof ReadWriteInstruction rwInstruction) { final String name = rwInstruction.getName(); final PsiElement element = rwInstruction.getElement(); if (element != null && name != null && name.equals(nodeName) && instruction.num() < num) { try { if (scope.getDeclaredVariable(element, name) == null) { final ReadWriteInstruction.ACCESS access = rwInstruction.getAccess(); if (access.isReadAccess()) { first.set(false); return ControlFlowUtil.Operation.BREAK; } } } catch (DFALimitExceededException e) { first.set(false); } return ControlFlowUtil.Operation.CONTINUE; } } return ControlFlowUtil.Operation.NEXT; }); return first.get(); }