Support for unique_with

Hi Jan!

This is a little change to support unique_with. I don't know if this is the best way, but it solves my problems.

Please, tell me any improvement you see.

Bast regards!