Filtering duplicate nodes out of graph