def enforce_deltas(candidate, last)
      candidate.each do |k,v|
        if v.is_a?(Hash)
          last[k] ||= {}
          candidate[k] = enforce_deltas(candidate[k], last[k])
          candidate.delete(k) if candidate[k].empty?
        else
          if last[k] == v
            candidate.delete(k)
          else
            last[k] = candidate[k]
          end
        end
      end
      candidate
    end
def enforce_deltas(candidate, last)
      candidate.each do |k,v|
        if v.is_a?(Hash)
          last[k] ||= {}
          candidate[k] = enforce_deltas(candidate[k], last[k])
          candidate.delete(k) if candidate[k].empty?
        else
          if last[k] == v
            candidate.delete(k)
          else
            last[k] = candidate[k]
          end
        end
      end
      candidate
    end
Take two hashes and enforce delta reporting.
 We only report when values change (instead of reporting all of
 the time).  This is a recursive method.

 @param [Hash] the payload have delta reporting applied to
 @param [Hash] a hash of the last values reported

 @return [Hash] the candidate hash with delta reporting applied