/// <summary> /// Traverse a factor tree and creates a Dictionary for caching. /// </summary> /// <param name="factorTreeNodes">The Dictionary for caching.</param> /// <param name="children">Children factor trees to add to the dictionary.</param> private void AddFactorTreeChildren(Dictionary <int, IFactorTreeNode> factorTreeNodes, FactorTreeNodeList children) { if (children.IsNotEmpty()) { foreach (IFactorTreeNode child in children) { if (!factorTreeNodes.ContainsKey(child.Id)) { factorTreeNodes.Add(child.Id, child); } AddFactorTreeChildren(factorTreeNodes, child.Children); } } }