protected function getPreferredQuality(array $qualityParts, $name)
    {
        $i = 0;
        $quality = 0;
        $selectedName = '';

        foreach ($qualityParts as $accept) {
            if ($i == 0) {
                $quality = $accept['quality'];
                $selectedName = $accept[$name];
            } else {
                $acceptQuality = $accept['quality'];
                $preferredQuality = ($quality < $acceptQuality);

                if ($preferredQuality === true) {
                    $quality = $acceptQuality;
                    $selectedName = $accept[$name];
                }
            }
            $i++;
        }

        return $selectedName;
    }