Filter duplicates on parent() and ascend()

Also add some unit tests for duplicate filtering