public function setDimensions(array $dimensionsToBeSet)
    {
        if ($this->dimensions->count() === 0) {
            $this->dimensions = new ArrayCollection($dimensionsToBeSet);
            $this->buildDimensionValues();
            return;
        }

        $expectedDimensions = [];
        /** @var NodeDimension $dimensionToBeSet */
        foreach ($dimensionsToBeSet as $dimensionToBeSet) {
            $dimensionToBeSet->setNodeData($this);
            $existingDimension = $this->findExistingDimensionMatching($dimensionToBeSet);
            $expectedDimensions[] = $existingDimension !== null ? $existingDimension : $dimensionToBeSet;
            if ($existingDimension === null) {
                $this->dimensions->add($dimensionToBeSet);
            }
        }

        // remove entries not to be set
        $dimensionsToRemove = $this->dimensions->filter(function (NodeDimension $dimension) use ($expectedDimensions) {
            return (array_search($dimension, $expectedDimensions) === false);
        });

        foreach ($dimensionsToRemove as $dimension) {
            $this->dimensions->removeElement($dimension);
        }

        $this->buildDimensionValues();
    }