/// <summary>
 /// Create a Factor tree node instance.
 /// </summary>
 /// <param name='factor'>Factor belonging to this factor tree node.</param>
 public FactorTreeNode(Factor factor)
     : base(factor.Id, factor.SortOrder)
 {
     _factor   = factor;
     _children = new FactorTreeNodeList();
     _parents  = new FactorTreeNodeList();
 }
        /// <summary>
        /// Get all factor tree nodes that belongs
        /// to this factor tree node.
        /// This tree node is also included in the result.
        /// </summary>
        public FactorTreeNodeList GetAllChildTreeNodes()
        {
            FactorTreeNodeList factorTreeNodeList;

            factorTreeNodeList = new FactorTreeNodeList();
            factorTreeNodeList.Add(this);
            if (_children.IsNotEmpty())
            {
                foreach (FactorTreeNode child in _children)
                {
                    factorTreeNodeList.AddRange(child.GetAllChildTreeNodes());
                }
            }
            return(factorTreeNodeList);
        }
        /// <summary>
        /// Get all leafs that belongs to this factor tree node.
        /// This tree node may also be included in the result.
        /// </summary>
        public FactorTreeNodeList GetAllLeafTreeNodes()
        {
            FactorTreeNodeList leafs;

            leafs = new FactorTreeNodeList();
            if (_children.IsEmpty())
            {
                leafs.Add(this);
            }
            else
            {
                foreach (FactorTreeNode child in _children)
                {
                    leafs.AddRange(child.GetAllLeafTreeNodes());
                }
            }
            return(leafs);
        }