/// <summary> /// Creates ADD operations for the node and ALL of its children. /// </summary> /// <param name="node">The node.</param> /// <param name="idGenerator">The temporary ID generator for new nodes.</param> /// <returns>A list of operation pair for the specified operation and nodes. /// </returns> private List <OperationPair> CreateAddOperations(ProductPartitionNode node, TemporaryIdGenerator idGenerator) { AdGroupCriterionOperation addOp = new AdGroupCriterionOperation(); addOp.@operator = Operator.ADD; // Overwrite the ID set by the user when doing ADD operations. This // minimizes the chances of a malformed tree. node.ProductPartitionId = idGenerator.Next; addOp.operand = ProductPartitionNodeAdapter.CreateCriterionForAdd(node, adGroupId, idGenerator); List <OperationPair> operationsList = new List <OperationPair>(); operationsList.Add(new OperationPair(node, addOp)); // Recursively add all of this node's children to the operations list. foreach (ProductPartitionNode child in node.Children) { operationsList.AddRange(CreateAddOperations(child, idGenerator)); } return(operationsList); }