public void ResolveExtend()
        {
            ResolveExtendData();
            // Ensure we process derivations in right order (topologic) so no lingering extend stays:
            var derivations = TopologicalSort(ParentToChildren.Values.ToList());

            // Apply Derivations:
            foreach (var derivation in derivations)
            {
                if (derivation.ParentRule == null)
                {
                    Debug.LogWarning("Cannot resolve parent rule: " + derivation.ParentSelectorName);
                    continue;
                }

                var extendedRules = derivation.ParentRule.ResolveExtendedRules(this);
                foreach (var childrenRule in derivation.ChildrenRules)
                {
                    foreach (var replacementRule in extendedRules)
                    {
                        var childrenReplacementName = replacementRule.SelectorName.Replace(derivation.ParentSelectorName, childrenRule.SelectorName);
                        if (childrenRule.SelectorName == childrenReplacementName)
                        {
                            childrenRule.Properties.Remove(ConverterUtils.k_Extend);
                            Extend(replacementRule, childrenRule);
                        }
                        else
                        {
                            Rule pseudoChildrenRule;
                            if (!Rules.TryGetValue(childrenReplacementName, out pseudoChildrenRule))
                            {
                                var childrenSelector = ConverterUtils.CreateSelectorFromSource(replacementRule.Selector, childrenRule.SelectorName);
                                pseudoChildrenRule = new Rule(childrenReplacementName, childrenSelector, -1);
                                Rules.Add(childrenReplacementName, pseudoChildrenRule);
                                RecordIfPseudoStateRule(pseudoChildrenRule);
                            }

                            Extend(replacementRule, pseudoChildrenRule);
                        }
                    }
                }
            }
        }