bfs reimplemented with BFSNode to encapsulate moves