Use a set to speed up #is_collection?

This gives a boost of about 50% on the last part of the method (last 2 lines of this gist https://gist.github.com/ccocchi/b74045f5e3c15db44dce)