protected function parseChoices(array $choices)
    {
        $items = [];

        foreach ($choices as $key => $value) {
            if (is_array($value)) {
                // Handle options groups data.
                $items[] = ['key' => $key, 'value' => '', 'type' => 'group'];
                $items = array_merge($items, $this->parseChoices($value));
            } else {
                $items[] = ['key' => $key, 'value' => $value, 'type' => 'option'];
            }
        }

        return $items;
    }