private long TrimResult()
        {
            if (_lastHeader == null)
            {
                return(0L);
            }

            // Trim zero byte stuffing from last header (if any)
            string zeroByteStuffingName      = Enum.GetName(typeof(NalUnitParser.Attribute), NalUnitParser.Attribute.TrailingZeroBytes);
            var    zeroByteStuffingAttribute = _lastHeader.FindAttributeByName(zeroByteStuffingName);

            if (zeroByteStuffingAttribute == null)
            {
                return(0L);
            }

            uint byteCount = (uint)zeroByteStuffingAttribute.Value;

            // Rebuild the last header, omitting the zero byte stuffing attribute
            var resultNodeBuilder = new ResultNodeBuilder
            {
                Name       = _lastHeader.Name,
                Metadata   = _lastHeader,
                DataPacket = _lastHeader.GetSubPacket(0, (_lastHeader.Length - byteCount))
            };

            foreach (IResultAttribute attribute in _lastHeader.Attributes.Where(a => a.Name != zeroByteStuffingName))
            {
                resultNodeBuilder.AddAttribute(attribute);
            }

            // Replace the last header with the new (trimmed) header
            IResultNode parent = _lastHeader.Parent;

            parent.RemoveChild(_lastHeader);
            parent.AddChild(resultNodeBuilder.Build());

            // Compensate end offset for zero byte trimming
            return(-byteCount);
        }