Self (final ElementPattern<XmlTag> rootTag) { return with(new PatternCondition<>("withRootTag") { @Override public boolean accepts(@NotNull final XmlFile xmlFile, final ProcessingContext context) { XmlDocument document = xmlFile.getDocument(); return document != null && rootTag.accepts(document.getRootTag(), context); } }); }