Deep object comparison function in JS