async def _process_child_databases(
        self, client: httpx.AsyncClient
    ) -> AsyncGenerator[ChunkEntity, None]:
        """Process child databases discovered during page content extraction."""
        logger.info("Phase 5: Processing child databases")

        # Process child databases until no new ones are discovered
        while self._child_databases_to_process:
            # Get databases that haven't been processed yet
            unprocessed_databases = [
                db_id
                for db_id in self._child_databases_to_process
                if db_id not in self._processed_databases
            ]

            if not unprocessed_databases:
                break

            logger.info(f"Processing {len(unprocessed_databases)} child databases")

            for database_id in unprocessed_databases:
                try:
                    logger.info(f"Processing child database: {database_id}")

                    # Get database schema
                    schema = await self._get_with_auth(
                        client, f"https://api.notion.com/v1/databases/{database_id}"
                    )

                    # Get breadcrumbs for this child database
                    breadcrumbs = self._child_database_breadcrumbs.get(database_id, [])

                    # Create database entity with proper breadcrumbs
                    database_entity = self._create_database_entity(schema)
                    database_entity.breadcrumbs = breadcrumbs
                    yield database_entity
                    self._processed_databases.add(database_id)

                    # Process all pages in this child database
                    async for page in self._query_database_pages(client, database_id):
                        page_id = page["id"]
                        if page_id in self._processed_pages:
                            continue

                        try:
                            # Create breadcrumbs for child database pages
                            page_breadcrumbs = breadcrumbs + [
                                Breadcrumb(
                                    entity_id=database_id,
                                    name=database_entity.title,
                                    type="database",
                                )
                            ]

                            # Always use lazy loading for better performance
                            page_entity = await self._create_lazy_page_entity(
                                page, page_breadcrumbs, database_id, schema
                            )
                            yield page_entity

                            # Don't yield files separately - they'll be handled
                            # during materialization
                            self._processed_pages.add(page_id)

                        except Exception as e:
                            logger.error(
                                f"Error processing child database page {page_id}: {str(e)}"
                            )
                            continue

                except Exception as e:
                    logger.error(f"Error processing child database {database_id}: {str(e)}")
                    continue
Process child databases discovered during page content extraction.
backend/airweave/platform/sources/notion.py