Fixed use of filter for py3 compatibility.
Changed equality check to identity check for correct behaviour with custom objects.