code: def detect_circle(nodes):
      
      # Verify nodes and traveled types
      if not isinstance(nodes, dict):
          raise TypeError('"nodes" must be a dictionary')
  
      dependencies = set(nodes.keys())
      traveled = []
  
      heads = _detect_circle(nodes, dependencies, traveled)
  
      return DependencyTree(heads)
docs: Wrapper for recursive _detect_circle function