/// <summary>
        /// Determines if we should collapse with the old ruleset.
        /// </summary>
        /// <param name="hashKey"> hash key of last same ruleset occurs</param>
        /// <param name="ruleSetMediaPageDictionary"> Dictionary of hash keys and RulesetNodes</param>
        /// <param name="currentRuleSet"> RulesetNode currently tracking.</param>
        /// <param name="shouldPreventOrderBasedConflict">should prevent conflict.</param>
        /// <returns> Whether we should collapse or not.</returns>
        private static bool ShouldCollapseTheNewRuleset(string hashKey,
                                                        OrderedDictionary ruleSetMediaPageDictionary,
                                                        RulesetNode currentRuleSet,
                                                        bool shouldPreventOrderBasedConflict)
        {
            if (ruleSetMediaPageDictionary.Contains(hashKey))
            {
                if (!shouldPreventOrderBasedConflict)
                {
                    return(true);
                }

                // Dictionary for declarations
                var declarationNodeDictionary = new OrderedDictionary();
                var styleSheetRuleNodes       = ruleSetMediaPageDictionary.Values.Cast <StyleSheetRuleNode>().ToList();
                styleSheetRuleNodes.Reverse();

                // Iterate through all rulesetnodes.
                foreach (var previousStyleSheetRulesetNode in styleSheetRuleNodes)
                {
                    // If the node is actually RulesetNode instance
                    if (currentRuleSet.GetType().IsAssignableFrom(previousStyleSheetRulesetNode.GetType()))
                    {
                        // Previous Ruleset Node
                        var previousRulesetNode = previousStyleSheetRulesetNode as RulesetNode;

                        // If Ruleset node has same selectors set
                        if (previousRulesetNode.PrintSelector().Equals(currentRuleSet.PrintSelector()))
                        {
                            return(true);
                        }

                        // Add each declaration of the previous ruleset in the dictionary
                        foreach (var declaration in previousRulesetNode.Declarations)
                        {
                            string hashKeyForDeclaration = declaration.Property;
                            if (!declarationNodeDictionary.Contains(hashKeyForDeclaration))
                            {
                                declarationNodeDictionary[hashKeyForDeclaration] = declaration;
                            }
                        }

                        // Check if the last same RulesetNode has same declaration property
                        var lastRuleSet = (RulesetNode)ruleSetMediaPageDictionary[hashKey];
                        if (lastRuleSet.HasConflictingDeclaration(declarationNodeDictionary))
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }