private function getLegend(PaletteInterface $palette, $legendName)
    {
        if ($palette->hasLegend($legendName)) {
            return $palette->getLegend($legendName);
        }

        $legend = new Legend($legendName);
        $palette->addLegend($legend);

        return $legend;
    }