@staticmethod<EOL><INDENT>def cleanup_namespaces(tree_or_element, top_nsmap=None, keep_ns_prefixes=None):<DEDENT>
all_prefixes_to_keep = [<EOL>OneLogin_Saml2_Constants.NS_PREFIX_XS<EOL>]<EOL>if keep_ns_prefixes:<EOL><INDENT>all_prefixes_to_keep = list(set(all_prefixes_to_keep.extend(keep_ns_prefixes)))<EOL><DEDENT>return etree.cleanup_namespaces(tree_or_element, keep_ns_prefixes=all_prefixes_to_keep)<EOL>
Keeps the xmlns:xs namespace intact when etree.cleanup_namespaces is invoked.
:param tree_or_element: An XML tree or element
:type tree_or_element: etree.Element
:param top_nsmap: A mapping from namespace prefixes to namespace URIs
:type top_nsmap: dict
:param keep_ns_prefixes: List of prefixes that should not be removed as part of the cleanup
:type keep_ns_prefixes: list
:returns: An XML tree or element
:rtype: etree.Element