private static void findReferencesRec(VarExprent varExp, Statement stat, RootStatement root, List<VariablePosition> list) {
    if (stat.getExprents() != null) {
      for (Exprent e : stat.getExprents()) {
        findReferences(varExp, e, root, list);
      }
    } else {
      for (Object o : stat.getSequentialObjects()) {
        if (o instanceof Statement s) {
          findReferencesRec(varExp, s, root, list);
        } else if (o instanceof Exprent e) {
          findReferences(varExp, e, root, list);
        }
      }
    }
  }
Searches for where a variable is referenced and returns the context
src/org/jetbrains/java/decompiler/modules/decompiler/IntersectionCastProcessor.java