code: def _shortcutting(circuit):
      """Remove duplicate nodes in the path"""
      nodes = []
      for u, v in circuit:
          if v in nodes:
              continue
          if not nodes:
              nodes.append(u)
          nodes.append(v)
      nodes.append(nodes[0])
      return nodes
  
file_path: networkx/networkx/algorithms/approximation/traveling_salesman.py
imports: import math
  import networkx
  from networkx.algorithms.tree.mst import random_spanning_tree
  from networkx.utils import not_implemented_for, pairwise, py_random_state
label_desc: Use image node_id 4 for calling a global function with example usage: _shortcutting(circuit) and returns: nodes