Can't use len() on filter iterator. fix #2762
removeDuplicate helper