protected function addNewName(ServerRequestInterface $request, Tree $tree): string
    {
        $gedrec = "\n1 NAME " . $request->get('NAME', '');

        $tags = [
            'NPFX',
            'GIVN',
            'SPFX',
            'SURN',
            'NSFX',
        ];

        if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $tree->getPreference('ADVANCED_NAME_FACTS'), $match)) {
            $tags = array_merge($tags, $match[1]);
        }

        // Paternal and Polish and Lithuanian surname traditions can also create a _MARNM
        $SURNAME_TRADITION = $tree->getPreference('SURNAME_TRADITION');
        if ($SURNAME_TRADITION === 'paternal' || $SURNAME_TRADITION === 'polish' || $SURNAME_TRADITION === 'lithuanian') {
            $tags[] = '_MARNM';
        }

        foreach (array_unique($tags) as $tag) {
            $TAG = $request->get($tag, '');
            if ($TAG !== '') {
                $gedrec .= "\n2 {$tag} {$TAG}";
            }
        }

        return $gedrec;
    }