private DataGridCollectionViewGroup CreateSubGroup(object groupName, int level, ObservableCollection <GroupDescription> groupByList,
                                                           List <GroupSortComparer> groupSortComparers)
        {
            // If sortComparers is null, we are in massive group creation, no order check.
            DataGridCollectionViewGroup group = new DataGridCollectionViewGroup(groupName, this, m_nextSubGroupUnsortedIndex);

            unchecked
            {
                m_nextSubGroupUnsortedIndex++;
            }

            int index;

            if (groupSortComparers == null)
            {
                Debug.Assert(this.ProtectedItemCount == this.ProtectedItems.Count);
                index = this.ProtectedItemCount;
            }
            else
            {
                index = this.BinarySearchGroup(group, groupSortComparers[level]);

                if (index < 0)
                {
                    index = ~index;
                }
            }

            level++;

            if (level < groupByList.Count)
            {
                group.SetSubGroupBy(groupByList[level]);
                group.CreateFixedGroupNames(level, groupByList, groupSortComparers);
            }

            this.InsertGroup(index, group);
            return(group);
        }