async def _traverse_directory(
        self,
        client: httpx.AsyncClient,
        workspace_slug: str,
        repo_slug: str,
        path: str,
        breadcrumbs: List[Breadcrumb],
        branch: str,
        processed_paths: set,
    ) -> AsyncGenerator[ChunkEntity, None]:
        """Recursively traverse a directory using DFS.

        Args:
            client: HTTP client
            workspace_slug: Workspace slug
            repo_slug: Repository slug
            path: Current path to traverse
            breadcrumbs: Current breadcrumb chain
            branch: Branch name
            processed_paths: Set of already processed paths

        Yields:
            Directory and file entities
        """
        if path in processed_paths:
            return

        processed_paths.add(path)

        # Get contents of the current directory
        url = f"{self.BASE_URL}/repositories/{workspace_slug}/{repo_slug}/src/{branch}/{path}"

        try:
            contents = await self._get_paginated_results(client, url)

            # Process each item in the directory
            for item in contents:
                item_path = item["path"]
                item_type = item.get("type", "file")

                if item_type == "commit_directory":
                    # Create directory entity
                    dir_entity = BitbucketDirectoryEntity(
                        entity_id=f"{workspace_slug}/{repo_slug}/{item_path}",
                        source_name="bitbucket",
                        path=item_path,
                        repo_slug=repo_slug,
                        repo_full_name=f"{workspace_slug}/{repo_slug}",
                        workspace_slug=workspace_slug,
                        content=f"Directory: {item_path}",
                        breadcrumbs=breadcrumbs.copy(),
                        url=f"https://bitbucket.org/{workspace_slug}/{repo_slug}/src/{branch}/{item_path}",
                    )

                    # Create breadcrumb for this directory
                    dir_breadcrumb = Breadcrumb(
                        entity_id=dir_entity.entity_id,
                        name=Path(item_path).name,
                        type="directory",
                    )

                    # Yield the directory entity
                    yield dir_entity

                    # Create updated breadcrumb chain for children
                    dir_breadcrumbs = breadcrumbs.copy() + [dir_breadcrumb]

                    # Recursively traverse this directory (DFS)
                    async for child_entity in self._traverse_directory(
                        client,
                        workspace_slug,
                        repo_slug,
                        item_path,
                        dir_breadcrumbs,
                        branch,
                        processed_paths,
                    ):
                        yield child_entity

                elif item_type == "commit_file":
                    # Check if we should include this file
                    if self._should_include_file(item_path):
                        # Process the file and yield entities
                        async for file_entity in self._process_file(
                            client, workspace_slug, repo_slug, item_path, item, breadcrumbs, branch
                        ):
                            yield file_entity

        except Exception as e:
            logger.error(f"Error traversing path {path}: {str(e)}")
Recursively traverse a directory using DFS.

        Args:
            client: HTTP client
            workspace_slug: Workspace slug
            repo_slug: Repository slug
            path: Current path to traverse
            breadcrumbs: Current breadcrumb chain
            branch: Branch name
            processed_paths: Set of already processed paths

        Yields:
            Directory and file entities
        
backend/airweave/platform/sources/bitbucket.py