Minimalistic A* implementation