public void SelectDirectory(DirectoryEntryViewModel directoryEntry, TreeView treeView, Action beforeSelectItem, Action afterSelectItem)
        {
            if (ReferenceEquals(CurrentRootNodesViewModel, _fileSystemEntryRootNodes))
            {
                return;
            }

            var chromiumRoot = GetChromiumRoot(directoryEntry);

            var entryViewModel =
                _fileSystemEntryRootNodes.OfType <DirectoryEntryViewModel>()
                .FirstOrDefault(x => SystemPathComparer.Instance.Comparer.Equals(x.Name, chromiumRoot.Name));

            if (entryViewModel == null)
            {
                return;
            }

            foreach (var childName in directoryEntry.Name.Split(Path.DirectorySeparatorChar))
            {
                var childViewModel = entryViewModel
                                     .Children
                                     .OfType <DirectoryEntryViewModel>()
                                     .FirstOrDefault(x => SystemPathComparer.Instance.Comparer.Equals(x.Name, childName));
                if (childViewModel == null)
                {
                    entryViewModel.EnsureAllChildrenLoaded();
                    childViewModel = entryViewModel
                                     .Children
                                     .OfType <DirectoryEntryViewModel>()
                                     .FirstOrDefault(x => SystemPathComparer.Instance.Comparer.Equals(x.Name, childName));
                    if (childViewModel == null)
                    {
                        return;
                    }
                }

                entryViewModel = childViewModel;
            }

            SwitchToFileSystemTree();
            entryViewModel.IsExpanded = true;
            entryViewModel.IsSelected = true;
            WpfUtilities.Invoke(treeView, DispatcherPriority.ApplicationIdle, () => {
                try {
                    beforeSelectItem();
                    try {
                        WpfUtilities.SelectItem(treeView, entryViewModel);
                    }
                    finally {
                        afterSelectItem();
                    }
                }
                catch (Exception e) {
                    Logger.LogException(e, "Error updating TreeView UI to show selected item.");
                }
            });
        }