Modified contains() builtin function to be able to handle collections of entities.