public static Throwable getRootCause(Throwable throwable) {
    if (throwable.getCause() == null) {
      return throwable;
    }

    Throwable cause;
    while ((cause = throwable.getCause()) != null) {
      throwable = cause;
    }
    return throwable;
  }
Get the root cause of a {@link Throwable}. Returns the specified {@code throwable} if its
{@code getCause} returns null.

@param throwable the {@code Throwable} to get the root cause of.
@return the root cause of the specified {@code throwable}.

@throws NullPointerException if {@code throwable} is null
geode-core/src/main/java/org/apache/geode/internal/lang/ThrowableUtils.java