if (target?.$and) {
    target.$and = cleanAnd(target.$and as Record<string, unknown>[]);
    if (!target.$and) {
      delete target.$and;
    }