public static Throwable rootCause(Throwable e) {
        Throwable cause = e;
        while (cause.getCause() != null) {
            cause = e.getCause();
        }
        return cause;
    }
Gets the root cause of an exception.
@param e the root cause
@return the throwable
common/es/src/main/java/io/apiman/common/es/util/EsUtils.java