docs: @SuppressWarnings("unchecked")
      public <T extends Throwable> T causeOfType(Class<T> type)
      {
          IdentityHashMap<Throwable, Throwable> seen =
              new IdentityHashMap<Throwable, Throwable>();
  
          Throwable cause = getCause();
          while (cause != null && ! type.isInstance(cause))
          {
              if (seen.put(cause, cause) != null)  // cycle check
              {
                  return null;
              }
              cause = cause.getCause();
          }
          return (T) cause;
      }