DFS impl in java