public static boolean isVariableUsed(@NotNull ControlFlow flow, int start, int end, @NotNull PsiVariable variable) {
    List<Instruction> instructions = flow.getInstructions();
    LOG.assertTrue(start >= 0, "flow start");
    LOG.assertTrue(end <= instructions.size(), "flow end");

    PsiManager psiManager = variable.getManager();
    for (int i = start; i < end; i++) {
      Instruction instruction = instructions.get(i);
      if (instruction instanceof ReadVariableInstruction) {
        if (psiManager.areElementsEquivalent(((ReadVariableInstruction)instruction).variable, variable)) {
          return true;
        }
      }
      else if (instruction instanceof WriteVariableInstruction) {
        if (psiManager.areElementsEquivalent(((WriteVariableInstruction)instruction).variable, variable)) {
          return true;
        }
      }
    }
    return false;
  }
public static boolean isVariableUsed(@NotNull ControlFlow flow, int start, int end, @NotNull PsiVariable variable)