private static Pair<List<Exprent>, Exprent> getCasts(Exprent exp) {
    // Gets the list of casts done and gets the original exprent
    List<Exprent> types = new ArrayList<>();
    Exprent inner = exp;
    while (inner instanceof FunctionExprent cast && isValidCast(cast)) {
      types.add(cast.getLstOperands().get(1));
      inner = cast.getLstOperands().get(0);
    }
    return Pair.of(types, inner);
  }
Searches for where a variable is referenced and returns the context
src/org/jetbrains/java/decompiler/modules/decompiler/IntersectionCastProcessor.java