Pre-compute the distance of the nodes in the nodeQueue once.