code: public static Throwable unwrap(Throwable ex) {
          if (canInspectCause(ex)) {
              Throwable cause = ex.getCause();
              if (cause != null) {
                  return unwrap(cause);
              }
          }
  
          return ex;
      }
docs: If the provided exception is a CompletionException or ExecutionException which need be unwrapped.
  
  @param ex The exception to be unwrapped.
  @return The cause or the exception provided.