bi-directional DFS