private static void findReferences(VarExprent varExp, Exprent exp, RootStatement root, List<VariablePosition> list) {
    if (exp instanceof InvocationExprent inv) {
      findReferences(varExp, inv, list);
    } else if (exp instanceof FunctionExprent func && func.getFuncType() == FunctionType.CAST) {
      if (func.getLstOperands().get(0) instanceof VarExprent otherVar && varExp.getVarVersionPair().equals(otherVar.getVarVersionPair())) {
        list.add(new VariablePosition(VariablePositionEnum.CASTED, exp, -1));
      }
    }
    for (Exprent sub : exp.getAllExprents()) {
      findReferences(varExp, sub, root, list);
    }
  }
Searches for where a variable is referenced and returns the context
src/org/jetbrains/java/decompiler/modules/decompiler/IntersectionCastProcessor.java