A function to test for identity-based deep equality