NumPy allowed · plain Python earns 10 bonus points
Implement span-tree reconstruction, assembling flat trace spans (each with a parent reference) into the real hierarchical call tree an observability UI actually displays.
Implement build_span_tree(spans). Each span is {"id": str, "parent_id": str|None, "name": str}. Return a nested dict for the ROOT span (the one with parent_id is None): {"name": str, "children": [recursively nested child dicts]}, where children are sorted by id for determinism. Assume exactly one root exists.
build_span_tree(spans: list[dict]) -> dict