boolean (@NotNull final ControlFlow flow, @NotNull Set<? extends PsiVariable> readVars, final int startOffset, final int stopPoint) { class MyVisitor extends InstructionClientVisitor<Boolean> { private boolean reachable = false; @Override public void visitInstruction(Instruction instruction, int offset, int nextOffset) { if (offset == stopPoint || isWriteToReadVar(instruction)) { // since it's dfs if we even already found some reads, they happened after stop point or after reassignment reachable = false; return; } boolean foundRead = instruction instanceof ReadVariableInstruction && readVars.contains(((ReadVariableInstruction)instruction).variable); reachable |= foundRead; } private boolean isWriteToReadVar(Instruction instruction) { return instruction instanceof WriteVariableInstruction && readVars.contains(((WriteVariableInstruction)instruction).variable); } @Override public Boolean getResult() { return reachable; } } MyVisitor visitor = new MyVisitor(); depthFirstSearch(flow, visitor, startOffset, flow.getSize()); return visitor.getResult(); }