Capgemini Invent delivery pipelines may need to inspect a nested collection of files before processing analytics inputs. Implement a function that traverses an in-memory directory tree, finds files with a requested extension, and returns their paths and sizes.
Use a nested dictionary to represent the directory structure. Each dictionary key is a file or directory name. A dictionary value represents a subdirectory, while an integer value represents a file size in bytes. The input dictionary represents the root directory and has no name of its own.
Return a dictionary with files and total_size keys. files must contain matching file records with path and size fields, ordered lexicographically by full path. Match the extension exactly and case-sensitively. A file matches when its name ends with the requested extension.
tree, a nested dictionary whose values are either dictionaries or non-negative integers, and extension, a non-empty string such as .csv.files, a list of {"path": string, "size": integer} records, and total_size, the sum of matching file sizes./ characters./ charactersdef process_files(tree, extension):