@KerrekSB: That's the other solution given on SO, though as one of the comments points out, it won't work for nested collections.