private static boolean isUnused(PsiElement obj, Query<PsiReference> query) {
        if (obj instanceof XsltParameter) {
            final Collection<PsiReference> references = query.findAll();
            int n = references.size();
            for (PsiReference reference : references) {
                final PsiElement element = reference.getElement();
                if (element instanceof XmlAttributeValue) {
                    final XmlAttribute parent = (XmlAttribute)element.getParent();
                    if ("name".equals(parent.getName())) {
                        final XmlTag tag = parent.getParent();
                        if (tag != null && "with-param".equals(tag.getLocalName())) {
                            n--;
                        }
                    }
                }
            }
            return n == 0;
        } else {
            return query.findFirst() == null;
        }
    }
private static boolean isUnused(PsiElement obj, Query<PsiReference> query)