XmlTag (XmlTag templateTag) { final XmlTag[] lastParam = new XmlTag[1]; templateTag.processElements(new PsiElementProcessor() { @Override public boolean execute(@NotNull PsiElement element) { if (element instanceof XmlTag) { if ("with-param".equals(((XmlTag)element).getLocalName())) { lastParam[0] = (XmlTag)element; } else { return false; } } return true; } }, templateTag); return lastParam[0]; }