code: func findGroupCycle(name string, groups map[string]*protocol.AuthGroup) []string {
  	// Set of groups that are completely explored (all subtree is traversed).
  	visited := map[string]bool{}
  
  	// Stack of groups that are being explored now. In case a cycle is detected
  	// it would contain that cycle.
  	var visiting []string
  
  	// Recursively explores `group` subtree, returns true if finds a cycle.
  	var visit func(string) bool
  	visit = func(group string) bool {
  		g := groups[group]
  		if g == nil {
  			visited[group] = true
  			return false
  		}
  		visiting = append(visiting, group)
  		for _, nested := range g.GetNested() {
  			// Cross edge. Can happen in diamond-like graph, not a cycle.
  			if visited[nested] {
  				continue
  			}
  			// Is `group` references its own ancestor -> cycle is detected.
  			for _, v := range visiting {
  				if v == nested {
  					return true
  				}
  			}
  			// Explore subtree.
  			if visit(nested) {
  				return true
  			}
  		}
  		visiting = visiting[:len(visiting)-1]
  		visited[group] = true
  		return false
  	}
  
  	visit(name)
  	return visiting // will contain a cycle, if any
  }
docs: // findGroupCycle searches for a group dependency cycle that contains group
  // `name`. Returns list of groups that form the cycle if found, empty list
  // if no cycles. Unknown groups are considered empty.