Use empty object as fallback when comparing to null/undefined

This makes #compare a little easier to use with nullable objects.

Change-Id: I272a437912ef3d96f2e28f377d5be945cf5aa8f1
Merge "Use empty object as fallback when comparing to null/undefined"