public static @Nullable XmlElement findElement(final @NotNull XmlElement parent, final @NotNull IElementType.Predicate predicate) {
    final Ref<XmlElement> result = new Ref<>();
    parent.processElements(new PsiElementProcessor<>() {
      @Override
      public boolean execute(@NotNull PsiElement element) {
        if (element instanceof XmlElement && predicate.matches(element.getNode().getElementType())) {
          result.set((XmlElement)element);
          return false;
        }
        return true;
      }
    }, parent);

    return result.get();
  }
public static @Nullable XmlElement findElement(final @NotNull XmlElement parent, final @NotNull IElementType.Predicate predicate)