code: private static Set<ClassTemplateSpec> findTopLevelTypes(ClassTemplateSpec spec) {
      Set<ClassTemplateSpec> specs =
          new HashSet<ClassTemplateSpec>(ClassTemplateSpecs.allReferencedTypes(spec));
      specs.add(spec);
  
      Iterator<ClassTemplateSpec> iterator = specs.iterator();
      while (iterator.hasNext()) {
        ClassTemplateSpec entry = iterator.next();
        if (entry.getEnclosingClass() != null) {
          iterator.remove();
        }
      }
      return specs;
    }
docs: Currently, one ClassDefinition is provided per .pdsc file. But some of those .pdsc contain
  inline schema definitions that should be generated into top level classes.
  
  This method traverses the spec hierarchy, finding all specs that should be generated as top
  level classes.
  
  I've asked the rest.li team to consider restructuring the generator utilities so that one
  ClassDefinition per top level class is provided. If they restructure the utilities, this
  method should no longer be needed.