Jason’s faster node_distance impl.