private static boolean replaceCasts(FunctionExprent cast, List<Exprent> types, Exprent inner) {
    if (types.size() > 1) {
      // Reorders the list of types to make sure that the class is always first
      Exprent nonInterface = null;
      for (Exprent type : types) {
        StructClass clazz = DecompilerContext.getStructContext().getClass(type.getExprType().value);
        if (clazz != null && !clazz.hasModifier(CodeConstants.ACC_INTERFACE)) {
          if (nonInterface == null) {
            nonInterface = type;
          } else {
            return false;
          }
        }
      }
      if (nonInterface != null) {
        types.remove(types.indexOf(nonInterface));
        types.add(0, nonInterface);
      }
      // Replaces the operands of the cast with the casted exprent and the list of needed casts
      cast.getLstOperands().clear();
      cast.getLstOperands().add(inner);
      cast.getLstOperands().addAll(types);
      return true;
    }
    return false;
  }
Searches for where a variable is referenced and returns the context
src/org/jetbrains/java/decompiler/modules/decompiler/IntersectionCastProcessor.java