Generic A* algorithm for node.js