private static function findAssociation(AggregatorInterface $aggregator) : Association
    {
        $config = $aggregator->getConfig();
        $table = $config->getTable();
        $joinTable = $config->getJoinTable();

        foreach ($table->associations() as $association) {
            // skip unsupported associations
            if (! in_array($association->type(), ['manyToMany', 'manyToOne'])) {
                continue;
            }

            if ($association->className() !== $joinTable->getAlias()) {
                continue;
            }

            return $association;
        }

        throw new RuntimeException(sprintf(
            'Table "%s" has no association with "%s"',
            get_class($config->getTable()),
            $joinTable->getAlias()
        ));
    }