/// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>The new node.</returns>
        internal ProductPartitionNode Clone()
        {
            ProductDimension newDimension = null;

            if (this.Dimension != null)
            {
                newDimension = (ProductDimension)SerializationUtilities.CloneObject(
                    this.Dimension);
            }
            ProductPartitionNode newNode = new ProductPartitionNode(null, newDimension,
                                                                    this.ProductPartitionId, this.children.Comparer);

            newNode = CopyProperties(this, newNode);
            newNode.CloneChildrenFrom(this.Children);
            return(newNode);
        }
        /// <summary>
        /// Deeply clones each child in <paramref name="children"/> and attaches it
        /// to the current node.
        /// </summary>
        /// <param name="children">The children to clone</param>
        /// <returns>The minimum product partition ID found within the subtrees
        /// under <paramref name="children"/>.</returns>
        private void CloneChildrenFrom(IEnumerable <ProductPartitionNode> children)
        {
            foreach (ProductPartitionNode childNode in children)
            {
                if (!this.IsSubdivision)
                {
                    this.AsSubdivision();
                }

                // Clone the child and add it to newParent's collection of children.
                ProductDimension newDimension = (ProductDimension)SerializationUtilities.CloneObject(
                    childNode.Dimension);
                ProductPartitionNode newChild = this.AddChild(newDimension);
                newChild = CopyProperties(childNode, newChild);

                newChild.CloneChildrenFrom(childNode.Children);
            }
        }