code: public static @Nullable Throwable targetOf(@Nullable Throwable t) {
      if (t instanceof InvocationTargetException) {
        return ((InvocationTargetException) t).getTargetException();
      }
      return t;
    }
docs: Obtains the target of the given {@code Throwable}. If the {@code Throwable} is a {@code InvocationTargetException},
  this method will return the "target exception" (not the cause.) For other {@code Throwable}s, the same instance is
  returned unmodified.
  
  @param t the given {@code Throwable}.
  @return the target exception, if applicable. Otherwise, this method returns the same {@code Throwable} passed as
  argument.
  @see InvocationTargetException