code: public static Throwable getCause(Throwable thr) {
  		Throwable cause = thr.getCause();
  		while (cause != null && cause != thr && cause != cause.getCause() && cause.getCause() != null) {
  			cause = cause.getCause();
  		}
  		return cause == null ? thr : cause;
  	}
docs: Replies the cause of the given exception.
  
  @param thr the exception.
  @return the cause.