finished direction optimal bfs. starts with top-down bfs, switch to bottom-up when frontier is large, then switch back when frontier is small again.