Changing the look of the tree of RecursiveTreeIterator

Code
<?php

$tree 
= [
    
'level1' => [
        
'val1',
        
'val2',
        
'val3',
        
'level2' => [
            
'val4',
            
'val5',
        ],
    ],
];

$iterator = new RecursiveTreeIterator(
    new 
RecursiveArrayIterator($tree)
);

$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_LEFT' ');
$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_MID_HAS_NEXT'');
$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_MID_LAST'|');
$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_END_HAS_NEXT'-');
$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_END_LAST'\\');
$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_RIGHT' ');

echo 
'<pre>';
foreach (
$iterator as $val) {
    echo 
$val PHP_EOL;
}
echo 
'</pre>';
Result
 \ Array
 |- val1
 |- val2
 |- val3
 |\ Array
 ||- val4
 ||\ val5
Used Versions
PHP 8.2, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8