/// <summary>
        /// Gets a collection of namespace references from the element's
        /// parent document and namespace.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <returns>A collection of namespace references from the element's
        /// parent document and namespace.</returns>
        public static IEnumerable <NamespaceReference> AllNamespaceNodes(this LanguageElement source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source", "source is null.");
            }

            Contract.Ensures(Contract.Result <IEnumerable <NamespaceReference> >() != null, "Result will not be null.");

            var namespaceNodes = Enumerable.Empty <NamespaceReference>();

            if (source.InsideNamespace)
            {
                var parentNamespace = source.GetNamespace();
                if (parentNamespace != null)
                {
                    namespaceNodes = parentNamespace.NamespaceReferences();
                }
            }

            var parentDocument = source.GetParentDocument();

            if (parentDocument != null)
            {
                namespaceNodes = parentDocument.NamespaceReferences().Concat(namespaceNodes);
            }

            return(namespaceNodes);
        }