protected function parseArrayElements(\XMLReader $reader, $elementName, $currentNodeIdentifier)
    {
        $values = [];
        $depth = 0;

        // The following silences static code analysis warnings about undefined variables.
        // during runtime this doesn't happen, because the $reader must be at an ELEMENT,
        // thus the variables would be defined in the first case block before they can be
        // used.
        $currentType = null;
        $currentEncoding = null;
        $currentClassName = null;
        $currentIdentifier = null;

        do {
            switch ($reader->nodeType) {
                case \XMLReader::ELEMENT:
                    $depth++;
                    // __type="object" __classname="Neos\Media\Domain\Model\ImageVariant" __encoding="json"
                    $currentType = $reader->getAttribute('__type');
                    $currentClassName = $reader->getAttribute('__classname');
                    $currentEncoding = $reader->getAttribute('__encoding');
                    break;
                case \XMLReader::END_ELEMENT:
                    if ($reader->name === $elementName) {
                        return $values;
                    }
                    break;
                case \XMLReader::CDATA:
                case \XMLReader::TEXT:
                    $values[] = $this->convertElementToValue($reader, $currentType, $currentEncoding, $currentClassName, $currentNodeIdentifier, $elementName);
                    break;
            }
        } while ($reader->read());
    }