code: def dfs_loop_search(self, root):
          self.nodes[root]['dfs_loop_status'] = 'DFS_TEMPORARY_CHECKED'
          for child in self.nodes[root]["sons"]:
              child_status = self.nodes[child]['dfs_loop_status']
              if child_status == 'DFS_UNCHECKED':
                  self.dfs_loop_search(child)
                  child_status = self.nodes[child]['dfs_loop_status']
              if child_status == 'DFS_TEMPORARY_CHECKED':
                  self.nodes[child]['dfs_loop_status'] = 'DFS_LOOP_INSIDE'
                  self.nodes[root]['dfs_loop_status'] = 'DFS_LOOP_INSIDE'
              if child_status in ('DFS_NEAR_LOOP', 'DFS_LOOP_INSIDE'):
                  if self.nodes[root]['dfs_loop_status'] != 'DFS_LOOP_INSIDE':
                      self.nodes[root]['dfs_loop_status'] = 'DFS_NEAR_LOOP'
                  self.nodes[child]['dfs_loop_status'] = 'DFS_LOOP_INSIDE'
          if self.nodes[root]['dfs_loop_status'] == 'DFS_TEMPORARY_CHECKED':
              self.nodes[root]['dfs_loop_status'] = 'DFS_OK'