def dataset_dependency_asdict(
    dep: Optional[DatasetDependency],
) -> Optional[dict[str, Any]]:
    """
    Converting to dict with making sure we don't have any additional fields
    that could've been added with subclasses
    """
    if not dep:
        return None
    parsed = {
        k: dataclasses.asdict(dep)[k] for k in DatasetDependency.__dataclass_fields__
    }

    if dep.dependencies:
        parsed["dependencies"] = [
            dataset_dependency_asdict(d) for d in dep.dependencies
        ]

    return parsed

    Converting to dict with making sure we don't have any additional fields
    that could've been added with subclasses
    
tests/utils.py