public function buildAggregatorFor(Node $n) { return clone $n->isLeaf() ? $this->protoForLeaves : $this->protoForInternalNodes; }
/** * @param Node $hierarchyDescription * @return NodeAggregator */ private function buildAggregatorOfNodes(Node $hierarchyDescription) { return new NodeAggregator($hierarchyDescription->getName(), array_map(function (Node $childNode) { return $this->buildAggregatorOfNodes($childNode); }, $hierarchyDescription->getChildren()), $this->nodeAggregatorFactory->buildAggregatorFor($hierarchyDescription)); }