protected function _getRepositoryList(RepositoryInterface $repository, $associations)
    {
        $repositories = [
            $repository->getRegistryAlias() => $repository
        ];

        foreach ($associations as $association) {
            $association += [
                'association' => null,
                'children' => []
            ];

            if ($association['association'] === null) {
                throw new \InvalidArgumentException("Association does not have an association object set");
            }

            $associationRepository = $association['association']->getTarget();

            $repositories += $this->_getRepositoryList($associationRepository, $association['children'] ?: []);
        }

        return $repositories;
    }