private void SetupRows(TreeViewItem item, IList <TreeViewItem> rows) { rows.Add(item); if (item.hasChildren && !TreeView.IsChildListForACollapsedParent(item.children)) { if (this.m_Comparer.Col != UISystemProfilerTreeView.Column.Element || this.m_Comparer.isAscending) { item.children.Sort(this.m_Comparer); } foreach (TreeViewItem current in item.children) { this.SetupRows(current, rows); } } }