public function getQueryPathAndParent(PersistentCollectionInterface $coll, QueryBuilder $qb = null)
    {
        $collMapping = $coll->getMapping();
        $parent      = $coll->getOwner();
        $paths[]     = [$collMapping->name, null];

        while (($association = $this->uow->getParentAssociation($parent)) !== null) {
            list($mapping, $owner, $propertyName, $propertyKey) = $association;

            if ($mapping->reference) {
                break;
            }

            $parent  = $owner;
            $paths[] = [$propertyName, $propertyKey];
        }

        if ($qb === null) {
            $qb = $this->dm->createQueryBuilder(get_class($parent));
        }

        /** @var RootPath|null $path */
        $path = null;
        foreach (array_reverse($paths) as $pathValue) {
            list($pathName, $pathKey) = $pathValue;

            $path = $path === null ? $qb->attr($pathName) : $path->map($pathName);

            switch (gettype($pathKey)) {
                case 'string':
                    $path = $path->map($pathKey);
                    break;
                case 'integer':
                    $path = $path->i($pathKey);
                    break;
            }
        }

        return [$qb, $path, $parent];
    }