         }
         return false
     }
+}
+
+public func isEqualSmoothingModels(_ lhs: SmoothingModel?, _ rhs: SmoothingModel?) -> Bool {
+    if lhs == nil && rhs == nil {
+        return true
+    }
+    if let lhs = lhs, let rhs = rhs {
+        return lhs.isEqualTo(rhs)
+    }
+    return false
 }
 
 public struct StupidBackoff: SmoothingModel {

    public var forceUnigrams: Bool?
    public var tokenLimit: Int?
    public var highlight: Highlight?
    public var collateQuery: String?
    public var collateParams: [String: String]?
    public var collatePrune: Bool?
    public var smoothing: String?
    
    public init(field: String, text: String? = nil, prefix: String? = nil, regex: String? = nil, analyzer: String? = nil, size: Int? = nil, shardSize: Int? = nil) {
        self.field = field
        self.text = text
        self.prefix = prefix

        self.analyzer = analyzer
        self.size = size
        self.shardSize = shardSize
        self.maxErrors = maxErrors
        self.separator = separator
        self.realWordErrorLikelihood = realWordErrorLikelihood
        self.confidence = confidence
        self.gramSize = gramSize
        self.forceUnigrams = forceUnigrams
        self.tokenLimit = tokenLimit
        self.highlight = highlight
        self.collate = collate
        self.smoothing = smoothing
    }
    
    internal init(withBuilder builder: PhraseSuggestionBuilder) throws {
