add Hash.insert to DFS algorithm