private Expression tagCriterionToExpression(String key, Object value) {
    if (IS_ANY.test(key) && isListOrMap(value)) {
      // __any__ ors together its children
      return parse(value, Expression::or);
    } else if (IS_ALL.test(key) && isListOrMap(value)) {
      // __all__ ands together its children
      return parse(value, Expression::and);
    } else if (IS_NOT.test(key)) {
      // __not__ negates its children
      return not(parse(value));
    } else {
      //If only a key is provided, with no value, match any object tagged with that key.
      boolean isAny = value == null || IS_ANY.test(value.toString()) ||
        (value instanceof Collection<?> values &&
          values.stream().anyMatch(d -> d != null && IS_ANY.test(d.toString().trim())));
      //If a collection or single item are provided, match any of these values.
      List<?> values = (value instanceof Collection<?> items ? items : value == null ? List.of() : List.of(value))
        .stream().map(BooleanExpressionParser::unescape).toList();
      if (ConfigExpressionScript.isScript(key)) {
        var expression = ConfigExpressionScript.parse(ConfigExpressionScript.extractScript(key), context).simplify();
        if (isAny) {
          values = List.of();
        }
        var result = matchAnyTyped(null, expression, values);
        if (!values.isEmpty() && result.pattern() == null && !result.isMatchAnything() && !result.matchWhenMissing() &&
          expression instanceof ConfigExpression.Variable<?, ?>(var ignored,var name)) {
          if (name.equals("feature.source")) {
            return or(values.stream().filter(String.class::isInstance).map(String.class::cast)
              .map(Expression::matchSource).toList());
          } else if (name.equals("feature.source_layer")) {
            return or(values.stream().filter(String.class::isInstance).map(String.class::cast)
              .map(Expression::matchSourceLayer).toList());
          }
        }
        return result;
      }
      String field = unescape(key);
      if (isAny) {
        return matchField(field);
      } else {
        return matchAnyTyped(field, tagValueProducer.valueGetterForKey(key), values);
      }
    }
  }
Returns a boolean expression that determines whether a source feature matches a criteria defined in yaml config.

@param <T>              Type of input the expression takes
@param object           a map or list of tag criteria
@param tagValueProducer a TagValueProducer
@return a predicate which returns true if this criteria matches
planetiler-custommap/src/main/java/com/onthegomap/planetiler/custommap/BooleanExpressionParser.java