public static <T extends Throwable> T getRootCause(Throwable throwable, Class<T> clazz) {
    T result = null;
    while (throwable != null) {
      if (clazz.isInstance(throwable)) {
        result = (T) throwable;
      }
      throwable = throwable.getCause();
    }
    return result;
  }
Find the deepest Throwable in the chain of the throwables of the given class.
@param throwable
@param clazz
@param <T>
@return
ambry-utils/src/main/java/com/github/ambry/utils/Utils.java