Implemented DFS n traversal