/// <summary>
        /// Initializes a new instance of <see cref="CoverageNodeModel"/>.
        /// </summary>
        /// <param name="type">The type of coverage data this represents.</param>
        public CoverageNodeModel(CoverageNodeType type)
        {
            NodeType = type;

            switch (type)
            {
            case CoverageNodeType.CoverageFile:
                CodeType = CodeElementType.CoverageFile;
                break;

            case CoverageNodeType.Module:
                CodeType = CodeElementType.Module;
                break;

            case CoverageNodeType.Namespace:
                CodeType = CodeElementType.Namespace;
                break;

            case CoverageNodeType.Type:
                CodeType = CodeElementType.Class;
                break;

            case CoverageNodeType.Function:
                CodeType = CodeElementType.Function;
                break;

            default:
                throw Utility.UnreachableCode("unexpected node type.");
            }

            AdditionalData = new Dictionary <string, object>();

            Children = new ObservableCollection <CoverageNodeModel>();
            Children.CollectionChanged += ChildrenCollectionChanged;
        }
        /// <summary>
        /// Gets the closest ancestor of the given node type.
        /// </summary>
        /// <param name="type">The node type to search for.</param>
        /// <returns>
        /// The coverage node of the given type. If one is not found, <c>null</c> is returned.  If
        /// this node is of the given type, then this node will be returned.
        /// </returns>
        public CoverageNodeModel ClosestAncestor(CoverageNodeType type)
        {
            var node = this;

            while (node != null &&
                   node.NodeType != type)
            {
                node = node.Parent;
            }

            return(node);
        }