/// <summary>
        /// Returns a collection of child elements.
        /// </summary>
        public static IEnumerable <DependencyObject> Elements(this DependencyObject item)
        {
            Contract.Requires <ArgumentNullException>(item != null);
            Contract.Ensures(Contract.Result <IEnumerable <DependencyObject> >() != null);

            ILinqTree <DependencyObject> adapter = new VisualTreeAdapter(item);
            var res = adapter.Children();

            Contract.Assume(res != null);
            return(res);
        }
        /// <summary>
        /// Returns a collection of descendant elements.
        /// </summary>
        public static IEnumerable <DependencyObject> Descendants(this DependencyObject item)
        {
            ILinqTree <DependencyObject> adapter = new VisualTreeAdapter(item);

            foreach (var child in adapter.Children())
            {
                yield return(child);

                foreach (var grandChild in child.Descendants())
                {
                    yield return(grandChild);
                }
            }
        }
        /// <summary>
        /// Returns a collection of ancestor elements.
        /// </summary>
        public static IEnumerable <DependencyObject> Ancestors(this DependencyObject item)
        {
            ILinqTree <DependencyObject> adapter = new VisualTreeAdapter(item);

            var parent = adapter.Parent;

            while (parent != null)
            {
                yield return(parent);

                adapter = new VisualTreeAdapter(parent);
                parent  = adapter.Parent;
            }
        }