Updated to work without EqualityComparer
Works  with generic return types (thanks to Matt Ellis!)