def collect_namespaces(metadata):<EOL>
namespaces = {}  <EOL>if "<STR_LIT>" in metadata:<EOL><INDENT>for value in metadata["<STR_LIT>"].values():<EOL><INDENT>add_namespaces(collect_namespaces(value), namespaces)<EOL><DEDENT><DEDENT>if "<STR_LIT>" in metadata:<EOL><INDENT>add_namespaces(metadata["<STR_LIT>"], namespaces)<EOL><DEDENT>return namespaces<EOL>
Walk through the metadata object, collecting namespace declarations.