from pathlib import Path


def find_topology_workspace(start_path: Path) -> Path | None:
    """
    Find the RemotiveTopology workspace by looking for a .remotive folder
    in the current directory or any of its parent directories.

    Args:
        start_path (Path): The starting directory to search from.

    Returns:
        Path: The path to the RemotiveTopology workspace."""

    for dir in [start_path] + list(start_path.parents):
        remotive_dir = dir / ".remotive"
        if remotive_dir.is_dir():
            return dir
    return None
