protected function getLegend($name, $palette, $prevLegend = null)
    {
        if (strpos($name, '+') === 0) {
            $name = substr($name, 1);
        }

        if (!$palette->hasLegend($name)) {
            $palette->addLegend(new Legend($name), $prevLegend);
        }

        return $palette->getLegend($name);
    }