code: public static ClassLoader getRootLoader(ClassLoader self) {
          while (true) {
              if (self == null) return null;
              if (isRootLoaderClassOrSubClass(self)) return self;
              self = self.getParent();
          }
      }
docs: Iterates through the classloader parents until it finds a loader with a class
  named "org.codehaus.groovy.tools.RootLoader". If there is no such class
  <code>null</code> will be returned. The name is used for comparison because
  a direct comparison using == may fail as the class may be loaded through
  different classloaders.
  
  @param self a ClassLoader
  @return the rootLoader for the ClassLoader
  @see org.codehaus.groovy.tools.RootLoader
  @since 1.5.0