/// <summary>
        /// Refresh tree node data with all children at once.
        /// <param name="mode">indicate the mode</param>
        /// </summary>
        public void RefreshTreeData(TreeViewMode mode)
        {
            this.WalkerMode = mode;
            if (this.Elements.Count != 0)
            {
                this.Elements.Clear();
            }

            //Set parent of Root explicitly for testing.
            var ancestry = new DesktopElementAncestry(this.WalkerMode, this.SelectedElement);

            // Pre-count the ancestors in our bounded count, so that our count is accurate
            _elementCounter.TryAdd(ancestry.Items.Count);

            this.TopMostElement = ancestry.First;

            // clear children
            this.SelectedElement.Children?.ForEach(c => c.Dispose());
            this.SelectedElement.Children?.Clear();
            this.SelectedElement.UniqueId = 0;

            PopulateChildrenTreeNode(this.SelectedElement, ancestry.Last, ancestry.NextId);

            // do population of ancesters all togather with children
            var list = new List <A11yElement>(this.Elements);

            this.Elements.AddRange(ancestry.Items);

            // populate Elements first
            this.Elements.AsParallel().ForAll(e => e.PopulateAllPropertiesWithLiveData());

            // check whether there is any elements which couldn't be updated in parallel, if so, update it in sequence.
            var nuel = this.Elements.Where(e => e.Properties == null);

            if (nuel.Count() != 0)
            {
                nuel.ToList().ForEach(e => e.PopulateAllPropertiesWithLiveData());
            }

            // run tests
            list.AsParallel().ForAll(e =>
            {
                SuiteFactory.RunRules(e);
            });
        }
        /// <summary>
        /// Refresh tree node data with all children at once.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="mode"></param>
        /// <param name="showAncestry"></param>
        public void GetTreeHierarchy(A11yElement e, TreeViewMode mode)
        {
            var begin = DateTime.Now;

            this.WalkerMode = mode;

            //Set parent of Root explicitly for testing.
            A11yElement parent   = null;
            var         ancestry = new DesktopElementAncestry(this.WalkerMode, e);

            parent = ancestry.Last;

            this.RootElement = ancestry.First;

            // clear children
            e.Children?.ForEach(c => c.Dispose());
            e.Children?.Clear();

            // populate selected element relationship and add it to list.
            e.Parent         = ancestry.Last;
            e.TreeWalkerMode = this.WalkerMode; // set tree walker mode.
            e.UniqueId       = 0;               // it is the selected element which should be id 0.
            this.Elements.Add(e);

            PopulateChildrenTreeNode(e, ancestry.NextId);

            // populate decendent Elements first in parallel
            this.Elements.AsParallel().ForAll(el =>
            {
                el.PopulateMinimumPropertiesForSelection();
            });

            // Add ancestry into Elements list.
            this.Elements.AddRange(ancestry.Items);

            this.LastWalkTime = DateTime.Now - begin;
        }