code: public static ElementSelector conditionalSelector(final Predicate<? super Element> predicate,
                                                        final ElementSelector es) {
  
          if (predicate == null) {
              throw new IllegalArgumentException("predicate must not be null");
          }
          if (es == null) {
              throw new IllegalArgumentException("es must not be null");
          }
          return new ElementSelector() {
              @Override
              public boolean canBeCompared(Element controlElement,
                                           Element testElement) {
                  return predicate.test(controlElement)
                      && es.canBeCompared(controlElement, testElement);
              }
          };
      }
docs: Applies the wrapped ElementSelector's logic if and only if the
  control element matches the given predicate.