class Exceptions {

    public static RuntimeException tryGetCassandraExceptionCause(RuntimeException exception)
    {
        Throwable cause = exception.getCause();
        if (cause instanceof CassandraException)
        {
            cause.addSuppressed(exception);
            return (CassandraException) cause;
        }
        else if (cause instanceof RuntimeException)
        {
            RuntimeException causeOfCause = tryGetCassandraExceptionCause((RuntimeException) cause);

            if (causeOfCause == cause) // NOPMD
            {
                return exception;
            }

            causeOfCause.addSuppressed(exception);
            return causeOfCause;
        }
        else
        {
            return exception;
        }
    }

    private  Exceptions();

}