def createGroupItem(self, grp, records, nextLevels=None, parent=None):
        """
        Creates the grouping item instance for the group with the given record
        information.
        
        :param      grp         | <variant>
                    record      | [<orb.Table>, ..] || <dict>
                    parent      | <QTreeWidgetItem> || <QTreeWidget>
        
        :return     <QTreeWidgetItem>
        """
        if parent is None:
            parent = self
        
        item = self.recordGroupClass(type(grp))(parent,
                                                grp,
                                                records,
                                                nextLevels)
        
        if parent == self and self.useGroupStyle():
            item.initGroupStyle()
        
        level = 0
        while parent and parent != self:
            level += 1
            parent = parent.parent()
        
        expand = self.autoExpand(level)
        if expand:
            try:
                item.load()
            except AttributeError:
                pass
            item.setExpanded(True)
        
        return item