protected function filterDuplicatesFromArray(array $values)
    {
        $uniqueItems = [];
        foreach ($values as $value) {
            $uniqueItems[md5(serialize($value))] = $value;
        }
        $result = array_values($uniqueItems);
        if (count($result) === 1) {
            return $result[0];
        }
        return $result;
    }