code: public static Throwable findExceptionCause( Throwable e )
    {
      Throwable error = e;
      Throwable cause = e;
      while( (error.getCause() != null) && (error.getCause() != error) )
      {
        cause = error.getCause();
        error = cause;
      }
      return cause;
    }
docs: Given an Exception, finds the root cause and returns it. This may end up
  returning the originally passed exception if that was the root cause.
  
  @param e the Throwable whose root cause should be located.
  
  @return the root Throwable, or e if it is the root.