code: private function getLegend(PaletteInterface $palette, $legendName)
      {
          if ($palette->hasLegend($legendName)) {
              return $palette->getLegend($legendName);
          }
  
          $legend = new Legend($legendName);
          $palette->addLegend($legend);
  
          return $legend;
      }
docs: Get a legend. Create it if not exists.
  
  @param PaletteInterface $palette    The palette.
  @param string           $legendName The name of the legend.
  
  @return LegendInterface