'Find the currently active prefix for the given namespace.'

def _prefix_for_namespace(self, namespace):

    if (namespace is None):
        return None
    for inverted_nsmap in reversed(self.nsmaps):
        if ((inverted_nsmap is not None) and (namespace in inverted_nsmap)):
            return inverted_nsmap[namespace]
    return None
