protected function resolvePrimaryIdByPipeline(array $pipeline) {
		foreach ($pipeline as $stage) {
			foreach ($stage as $name => $definition) {
				if ($name === '$group' && isset($definition['_id'])) {
					return ltrim($definition['_id'], '$');
				}
			}
		}
	}