code: public static Class<?> getOuterClass(Class<?> cl) {
      Class<?> enclosingClass;
      while ((enclosingClass = cl.getEnclosingClass()) != null) {
        cl = enclosingClass;
      }
      return cl;
    }
docs: Gets the outer class (a class with no enclosing class) that contains the
  given class.
  @param cl The <code>Class</code> for which to find the outer class.  If
  <code>class_</code> is an outer class, then <code>class_</code> is
  returned.
  @return The outer <code>Outer</code> class containing
  <code>class_</code>.