private IEnumerable <RootEntry> CreateRootEntries(List <VsHierarchy> oldHierarchies)
        {
            foreach (var hierarchy in oldHierarchies)
            {
                var rootPath = GetHierarchyRootPath(hierarchy);

                var projectEntry = _fileSystemTree.Projects
                                   .FirstOrDefault(x => SystemPathComparer.Instance.StringComparer.Equals(x.RootPath, rootPath));
                if (projectEntry == null)
                {
                    // Hierarchy should be deleted, as its root does not exist in new tree
                    yield return(new RootEntry {
                        RootPath = rootPath,
                        Hierarchy = hierarchy,
                        Builder = new IncrementalHierarchyBuilder(_templateFactory, hierarchy, new FullPath(rootPath),
                                                                  _fileSystemTree.Version, _nodeViewModelLoader, _imageSourceFactory)
                    });
                }
                else
                {
                    // Hierarchy should be updated with new root entry
                    yield return(new RootEntry {
                        RootPath = rootPath,
                        Hierarchy = hierarchy,
                        Builder = new IncrementalHierarchyBuilder(_templateFactory, hierarchy, new FullPath(rootPath),
                                                                  _fileSystemTree.Version, _nodeViewModelLoader, _imageSourceFactory)
                    });
                }
            }

            // Look for new hierarchies
            foreach (var projectEntry in _fileSystemTree.Projects)
            {
                var rootPath  = projectEntry.RootPath;
                var hierarchy = oldHierarchies
                                .FirstOrDefault(x => SystemPathComparer.Instance.StringComparer.Equals(GetHierarchyRootPath(x), rootPath));
                if (hierarchy == null)
                {
                    // A new hierarchy should be created
                    var newHierarchy = _hierarchy.CreateHierarchy();
                    yield return(new RootEntry {
                        RootPath = rootPath,
                        Hierarchy = newHierarchy,
                        Builder = new IncrementalHierarchyBuilder(_templateFactory, newHierarchy, new FullPath(rootPath),
                                                                  _fileSystemTree.Version, _nodeViewModelLoader, _imageSourceFactory)
                    });
                }
            }
        }
        private IEnumerable <RootEntry> CreateRootEntries(List <VsHierarchy> oldHierarchies)
        {
            foreach (var hierarchy in oldHierarchies)
            {
                var rootPath = GetHierarchyRootPath(hierarchy);

                var directoryEntry = _fileSystemTree.Root.Entries.FirstOrDefault(x => x.Name == rootPath);
                if (directoryEntry == null)
                {
                    // Hierarchy should be deleted, as its root does not exist in new tree
                    var fakeTree = new FileSystemTree {
                        Version = _fileSystemTree.Version,
                        Root    = new DirectoryEntry()
                        {
                            Name    = _fileSystemTree.Root.Name,
                            Entries = new List <FileSystemEntry>()
                        }
                    };
                    yield return(new RootEntry {
                        RootPath = rootPath,
                        FileSystemTree = fakeTree,
                        Hierarchy = hierarchy,
                        Builder = new IncrementalHierarchyBuilder(_templateFactory, hierarchy, fakeTree, _imageSourceFactory)
                    });
                }
                else
                {
                    // Hierarchy should be updated with new root entry
                    var fakeTree = new FileSystemTree {
                        Version = _fileSystemTree.Version,
                        Root    = new DirectoryEntry()
                        {
                            Name    = _fileSystemTree.Root.Name,
                            Entries = new List <FileSystemEntry> {
                                directoryEntry
                            }
                        }
                    };
                    yield return(new RootEntry {
                        RootPath = rootPath,
                        FileSystemTree = fakeTree,
                        Hierarchy = hierarchy,
                        Builder = new IncrementalHierarchyBuilder(_templateFactory, hierarchy, fakeTree, _imageSourceFactory)
                    });
                }
            }

            // Look for new hierarchies
            foreach (var directoryEntry in _fileSystemTree.Root.Entries)
            {
                var rootPath  = directoryEntry.Name;
                var hierarchy = oldHierarchies.FirstOrDefault(x => GetHierarchyRootPath(x) == rootPath);
                if (hierarchy == null)
                {
                    // A new hierarchy should be created
                    var fakeTree = new FileSystemTree {
                        Version = _fileSystemTree.Version,
                        Root    = new DirectoryEntry()
                        {
                            Name    = _fileSystemTree.Root.Name,
                            Entries = new List <FileSystemEntry> {
                                directoryEntry
                            }
                        }
                    };
                    var newHierarchy = _hierarchy.CreateHierarchy();
                    yield return(new RootEntry {
                        RootPath = rootPath,
                        FileSystemTree = fakeTree,
                        Hierarchy = newHierarchy,
                        Builder = new IncrementalHierarchyBuilder(_templateFactory, newHierarchy, fakeTree, _imageSourceFactory)
                    });
                }
            }
        }