public static Collection<String> getPrefixes(XmlElement context) {
        final XmlTag tag = PsiTreeUtil.getParentOfType(context, XmlTag.class);
        if (tag != null) {
            final HashSet<String> allPrefixes = new HashSet<>();
            final String[] uris = tag.knownNamespaces();
            for (String uri : uris) {
                for (XmlTag p = tag; p != null; p = p.getParentTag()) {
                    final Set<Map.Entry<String,String>> localPrefixes = p.getLocalNamespaceDeclarations().entrySet();
                    for (Map.Entry<String,String> entry : localPrefixes) {
                        final String prefix = entry.getKey();
                        if (!prefix.isEmpty() && entry.getValue().equals(uri)) {
                          allPrefixes.add(prefix);
                        }
                    }
                }
            }
            return allPrefixes;
        } else {
            return Collections.emptySet();
        }
    }
public static Collection<String> getPrefixes(XmlElement context)