private function processXmlGroup(\SimpleXMLElement $elm, array &$message, int &$segmentIdx, array &$array, array &$errors)
    {
        // init
        $groupVisited = false;
        $newGroup = [];

        for ($g = 0; $g < $elm['maxrepeat']; $g++) {
            $grouptemp = [];
            if ($message[$segmentIdx][0] != $elm->children()[0]['id']) {
                if (
                    !$groupVisited
                    &&
                    isset($elm['required'])
                ) {
                    $elmType = $elm['id']->__toString();
                    $fixed = false;
                    if (isset($this->groupTemplates[$elmType])) {
                        \array_splice($message, $segmentIdx, 0, $this->groupTemplates[$elmType]);
                        $fixed = true;
                    }

                    $errors[] = [
                        "text"      => $this->messageTextConf['MISSINGREQUIREDGROUP'] . " " . ($fixed ? '(patched)' : ''),
                        "position"  => $segmentIdx,
                        "segmentId" => $elmType,
                    ];
                } else {
                    break;
                }
            }

            foreach ($elm->children() as $elm2) {
                if ($elm2->getName() == "group") {
                    $this->processXmlGroup($elm2, $message, $segmentIdx, $grouptemp, $errors);
                } else {
                    $this->processXmlSegment($elm2, $message, $segmentIdx, $grouptemp, $errors);
                }
                $groupVisited = true;
            }

            $newGroup[] = $grouptemp;

        }

        if (\count($newGroup) === 0) {
            return;
        }

        $array[$elm['id']->__toString()] = $newGroup;
    }