protected function importTree( \XMLReader $xml, array $domains, $parentid = null, array $map = [] )
	{
		$total = 0;
		$childMap = [];
		$currentid = $parentid;

		while( $xml->read() === true )
		{
			if( $xml->nodeType === \XMLReader::ELEMENT && $xml->name === 'catalogitem' )
			{
				if( ( $node = $xml->expand() ) === false )
				{
					$msg = sprintf( 'Expanding "%1$s" node failed', 'catalogitem' );
					throw new \Aimeos\Controller\Jobs\Exception( $msg );
				}

				if( ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null ) {
					unset( $map[$attr->nodeValue] );
				}

				$currentid = $this->importNode( $node, $domains, $parentid, $childMap );
				$total++;
			}
			elseif( $xml->nodeType === \XMLReader::ELEMENT && $xml->name === 'catalog' )
			{
				$this->importTree( $xml, $domains, $currentid, $childMap );
				$childMap = [];
			}
			elseif( $xml->nodeType === \XMLReader::END_ELEMENT && $xml->name === 'catalog' )
			{
				\Aimeos\MShop::create( $this->getContext(), 'catalog' )->deleteItems( $map );
				break;
			}
		}
	}