private static boolean isValidCast(FunctionExprent cast) {
    if (cast.getFuncType() == FunctionType.CAST && cast.getLstOperands().size() == 2) {
      VarType type = cast.getLstOperands().get(1).getExprType();
      // Intersection casts cannot include arrays
      return type.typeFamily == TypeFamily.OBJECT && type.arrayDim == 0;
    }
    return false;
  }
Searches for where a variable is referenced and returns the context
src/org/jetbrains/java/decompiler/modules/decompiler/IntersectionCastProcessor.java