code: public static Throwable getUltimateCause(final Throwable throwable) {
      if (throwable.getCause() == null) {
        return throwable;
      } else {
        return getUltimateCause(throwable.getCause());
      }
    }
docs: Walks the .getCause() chain till it hits the leaf node.
  
  @param throwable a throwable object
  @return the most inner cause