private function flatten(?array $arr, string $group, ?string $lang = null): ?array
    {
        if ($arr === null) {
            return null;
        }

        if (!isset($this->arrayGroups[$group])) {
            throw new \OutOfBoundsException("Invalid group: $group");
        }

        if ($lang === null) {
            $lang = $this->lang;
        }

        if (!isset($this->arrayGroups[$group][$lang])) {
            throw new \OutOfBoundsException("Invalid language: $lang");
        }
        
        $keep = $this->arrayGroups[$group][$lang];
        
        if (!array_key_exists($keep, $arr)) {
            throw new \OutOfBoundsException("Invalid array index: $keep");
        }

        $arr[$group] = $arr[$keep];
        foreach ($this->arrayGroups[$group] as $g) {
            unset($arr[$g]);
        }
        
        return $arr;
    }