private void WriteItem(IReportWriter writer, MetricCounter counter)
        {
            CodeMetric current = counter.Group;
            int        ixDiff  = 0;

            while (ixDiff < _groupings.Length && _opened[ixDiff] != null && _groupings[ixDiff].Equals(current, _opened[ixDiff].Group))
            {
                ixDiff++;
            }

            //close open
            for (int ix = _groupings.Length - 1; ix >= ixDiff; ix--)
            {
                if (_opened[ix] != null)
                {
                    writer.StopItem(_heirarchy[ix], _opened[ix]);
                }
                _opened[ix] = null;
            }

            //open new
            for (int ix = ixDiff; ix < _opened.Length - 1 && _opened[ix] == null; ix++)
            {
                writer.StartItem(_heirarchy[ix], _opened[ix] = _heirarchy[ix][counter.Group]);
            }

            writer.WriteItem(_heirarchy[_heirarchy.Length - 1], counter);
        }