private IEnumerable<Bookmark> FindAll(IdentityPath identityPath, DocNode docNode)
 {
     var results = new List<Bookmark>();
     var transitionGroupDocNode = docNode as TransitionGroupDocNode;
     if (transitionGroupDocNode == null)
     {
         var docNodeParent = docNode as DocNodeParent;
         if (docNodeParent == null)
         {
             return results;
         }
         foreach (var child in docNodeParent.Children)
         {
             results.AddRange(FindAll(new IdentityPath(identityPath, child.Id), child));
         }
         return results;
     }
     if (!transitionGroupDocNode.HasResults)
     {
         return results;
     }
     for (int iReplicate = 0; iReplicate < transitionGroupDocNode.Results.Count; iReplicate++)
     {
         var replicate = transitionGroupDocNode.Results[iReplicate];
         if (replicate == null)
         {
             continue;
         }
         var fileDatas = new Dictionary<FinderChromFileKey, FinderChromFileData>();
         foreach (var transitionGroupChromInfo in replicate)
         {
             FinderChromFileData chromFileData;
             var chromFileKey = new FinderChromFileKey(transitionGroupChromInfo);
             if (!fileDatas.TryGetValue(chromFileKey, out chromFileData))
             {
                 chromFileData = new FinderChromFileData
                                     {
                                         TransitionGroupChromInfo = transitionGroupChromInfo,
                                         MatchingTransitionBookmarks = new List<Bookmark>(),
                                         AllTransitionsMatch = true,
                                     };
                 fileDatas.Add(chromFileKey, chromFileData);
             }
         }
         foreach (var transitionDocNode in transitionGroupDocNode.Transitions)
         {
             if (!transitionDocNode.HasResults || iReplicate >= transitionDocNode.Results.Count)
             {
                 continue;
             }
             var transitionResults = transitionDocNode.Results[iReplicate];
             if (transitionResults == null)
             {
                 continue;
             }
             var transitionId = new IdentityPath(identityPath, transitionDocNode.Id);
             foreach (var chromInfo in transitionResults)
             {
                 FinderChromFileData chromFileData;
                 bool match = MatchTransition(chromInfo) != null;
                 var transitionBookmark = new Bookmark(transitionId, chromInfo.FileId,
                                                       chromInfo.OptimizationStep);
                 var chromFileKey = new FinderChromFileKey(chromInfo);
                 if (!fileDatas.TryGetValue(chromFileKey, out chromFileData))
                 {
                     if (match)
                     {
                         results.Add(transitionBookmark);
                     }
                 }
                 else
                 {
                     if (match)
                     {
                         chromFileData.MatchingTransitionBookmarks.Add(transitionBookmark);
                     }
                     else
                     {
                         chromFileData.AllTransitionsMatch = false;
                     }
                 }
             }
         }
         foreach (var fileDataEntry in fileDatas)
         {
             if (fileDataEntry.Value.AllTransitionsMatch && fileDataEntry.Value.MatchingTransitionBookmarks.Count > 0)
             {
                 var transitionGroupMatch = MatchTransitionGroup(fileDataEntry.Value.TransitionGroupChromInfo);
                 if (transitionGroupMatch != null)
                 {
                     results.Add(new Bookmark(identityPath, fileDataEntry.Value.TransitionGroupChromInfo.FileId, fileDataEntry.Value.TransitionGroupChromInfo.OptimizationStep));
                     continue;
                 }
             }
             results.AddRange(fileDataEntry.Value.MatchingTransitionBookmarks);
         }
     }
     return results;
 }
        private IEnumerable <Bookmark> FindAll(IdentityPath identityPath, DocNode docNode)
        {
            var results = new List <Bookmark>();
            var transitionGroupDocNode = docNode as TransitionGroupDocNode;

            if (transitionGroupDocNode == null)
            {
                var docNodeParent = docNode as DocNodeParent;
                if (docNodeParent == null)
                {
                    return(results);
                }
                foreach (var child in docNodeParent.Children)
                {
                    results.AddRange(FindAll(new IdentityPath(identityPath, child.Id), child));
                }
                return(results);
            }
            if (!transitionGroupDocNode.HasResults)
            {
                return(results);
            }
            for (int iReplicate = 0; iReplicate < transitionGroupDocNode.Results.Count; iReplicate++)
            {
                var replicate = transitionGroupDocNode.Results[iReplicate];
                if (replicate == null)
                {
                    continue;
                }
                var fileDatas = new Dictionary <FinderChromFileKey, FinderChromFileData>();
                foreach (var transitionGroupChromInfo in replicate)
                {
                    FinderChromFileData chromFileData;
                    var chromFileKey = new FinderChromFileKey(transitionGroupChromInfo);
                    if (!fileDatas.TryGetValue(chromFileKey, out chromFileData))
                    {
                        chromFileData = new FinderChromFileData
                        {
                            TransitionGroupChromInfo    = transitionGroupChromInfo,
                            MatchingTransitionBookmarks = new List <Bookmark>(),
                            AllTransitionsMatch         = true,
                        };
                        fileDatas.Add(chromFileKey, chromFileData);
                    }
                }
                foreach (var transitionDocNode in transitionGroupDocNode.Transitions)
                {
                    if (!transitionDocNode.HasResults || iReplicate >= transitionDocNode.Results.Count)
                    {
                        continue;
                    }
                    var transitionResults = transitionDocNode.Results[iReplicate];
                    if (transitionResults == null)
                    {
                        continue;
                    }
                    var transitionId = new IdentityPath(identityPath, transitionDocNode.Id);
                    foreach (var chromInfo in transitionResults)
                    {
                        FinderChromFileData chromFileData;
                        bool match = MatchTransition(chromInfo) != null;
                        var  transitionBookmark = new Bookmark(transitionId, chromInfo.FileId,
                                                               chromInfo.OptimizationStep);
                        var chromFileKey = new FinderChromFileKey(chromInfo);
                        if (!fileDatas.TryGetValue(chromFileKey, out chromFileData))
                        {
                            if (match)
                            {
                                results.Add(transitionBookmark);
                            }
                        }
                        else
                        {
                            if (match)
                            {
                                chromFileData.MatchingTransitionBookmarks.Add(transitionBookmark);
                            }
                            else
                            {
                                chromFileData.AllTransitionsMatch = false;
                            }
                        }
                    }
                }
                foreach (var fileDataEntry in fileDatas)
                {
                    if (fileDataEntry.Value.AllTransitionsMatch && fileDataEntry.Value.MatchingTransitionBookmarks.Count > 0)
                    {
                        var transitionGroupMatch = MatchTransitionGroup(fileDataEntry.Value.TransitionGroupChromInfo);
                        if (transitionGroupMatch != null)
                        {
                            results.Add(new Bookmark(identityPath, fileDataEntry.Value.TransitionGroupChromInfo.FileId, fileDataEntry.Value.TransitionGroupChromInfo.OptimizationStep));
                            continue;
                        }
                    }
                    results.AddRange(fileDataEntry.Value.MatchingTransitionBookmarks);
                }
            }
            return(results);
        }