code: def loop_check(self):
          
          in_loop = []
          # Add the tag for dfs check
          for node in list(self.nodes.values()):
              node['dfs_loop_status'] = 'DFS_UNCHECKED'
  
          # Now do the job
          for node_id, node in self.nodes.items():
              # Run the dfs only if the node has not been already done */
              if node['dfs_loop_status'] == 'DFS_UNCHECKED':
                  self.dfs_loop_search(node_id)
              # If LOOP_INSIDE, must be returned
              if node['dfs_loop_status'] == 'DFS_LOOP_INSIDE':
                  in_loop.append(node_id)
  
          # Remove the tag
          for node in list(self.nodes.values()):
              del node['dfs_loop_status']
  
          return in_loop
docs: Check if we have a loop in the graph
  
          :return: Nodes in loop
          :rtype: list