Added node id generator and used mergeValue to simplify node map
algorithm