Faster implementation of filter.

This implementation improves performance a lot:
- Not enabling filtering detached elements flag (like jQuery does) is as faster as jQuery
- Enabling the flag is only 3 times slower instead of 50, It performs better in loops, specially decreasing time when creating ghost parents.

 Fixes issue #177 
I have used Julien's test example for measuring times.
https://github.com/manolo/testissue146/commits/master
Sorry I'm late for reviewing this patch again... 

Here `parents` should be a HashSet. if the order where the elements are added to the set is importnat, use a LinkedHashSet