slightly less confusing example and also recursive DFS impl