private UndirectedGraphNode helper(UndirectedGraphNode node, Map<Integer, UndirectedGraphNode> map) {

    UndirectedGraphNode newNode = new UndirectedGraphNode(node.label);
    if (!map.keySet().contains(node.label)) {
      map.put(node.label, newNode);
    }

    for (UndirectedGraphNode neighbor : node.neighbors) {
      if (!map.keySet().contains(neighbor.label)) {
        helper(neighbor, map);
      }
      newNode.neighbors.add(map.get(neighbor.label));
    }

    return newNode;
  }