integrated BFS and DFS; process(...) currently takes parameter for depth of BFS