A cybersecurity team at a healthcare SaaS provider scans customer “export bundles” before they’re uploaded to cloud storage. Each bundle is represented as a nested JSON-like object (Python dict) describing a directory tree. With millions of daily exports, the scanner needs a fast way to flatten this structure into a list of full file paths so downstream services can apply allow/deny rules and compute checksums.
You are given a nested object where:
dict[str, Any]).None, integers, strings). The value is metadata you should preserve.Implement flatten_directory(tree) that returns a flat dictionary mapping each full path to the corresponding file metadata.
/ as the separator./ (e.g., root/a.txt, not /root/a.txt)./.tree: dict[str, Any]dict[str, Any] where each key is a full path and each value is the original metadata.def _flatten_directory_test_adapter(**kwargs):