Self (@NotNull final ElementPattern pattern) { return with(new PatternCondition<>("isFirstSubtag") { @Override public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) { final XmlTag parent = xmlTag.getParentTag(); return parent != null && pattern.accepts(parent, context) && parent.getSubTags()[0] == xmlTag; } }); }