private function getConditionChain(LegendInterface $legend, $propertyName, array &$conditions)
    {
        // Cache condition chain for each legend property.
        if (isset($conditions[$legend->getName()][$propertyName])) {
            return $conditions[$legend->getName()][$propertyName];
        }

        $property = $this->getLegendProperty($legend, $propertyName);

        // There is no condition assigned to the property. Create an condition chain with an and conjunction
        // and add the condition condition chain for the sub palette with an or condition to it.
        $condition = $this->getVisibleCondition($property);

        $orCondition = new PropertyConditionChain();
        $orCondition->setConjunction(PropertyConditionChain::OR_CONJUNCTION);

        $conditions[$legend->getName()][$propertyName] = $orCondition;

        $condition->addCondition($orCondition);

        return $orCondition;
    }