private SectionHitGroup toGroup(Section section,Resolution resolution,Result result) {
        SectionHitGroup sectionGroup=new SectionHitGroup("section:" + section.getId());
        setField("id",section.getId(),sectionGroup);
        sectionGroup.setLeaf(section.elements(Section.class).size()==0);
        setField("layout",section.getLayout().getName(),sectionGroup);
        setField("region",section.getRegion(),sectionGroup);

        List<String> sourceList=new ArrayList<>();
        renderElements(resolution, result, sectionGroup, sourceList, section.elements());

        // Trim to max
        if (section.getMax()>=0)
            sectionGroup.trim(0,section.getMax());
        if (sectionGroup.size()>1)
            assignOrderer(section,resolution,sourceList,sectionGroup);

        return sectionGroup;
    }
Creates the hit group corresponding to a section, drawing data from the given result
container-search/src/main/java/com/yahoo/search/pagetemplates/engine/Organizer.java