code: func kRandomNodes(k int, nodes []*nodeState, filterFn func(*nodeState) bool) []*nodeState {
  	n := len(nodes)
  	kNodes := make([]*nodeState, 0, k)
  OUTER:
  	// Probe up to 3*n times, with large n this is not necessary
  	// since k << n, but with small n we want search to be
  	// exhaustive
  	for i := 0; i < 3*n && len(kNodes) < k; i++ {
  		// Get random node
  		idx := randomOffset(n)
  		node := nodes[idx]
  
  		// Give the filter a shot at it.
  		if filterFn != nil && filterFn(node) {
  			continue OUTER
  		}
  
  		// Check if we have this node already
  		for j := 0; j < len(kNodes); j++ {
  			if node == kNodes[j] {
  				continue OUTER
  			}
  		}
  
  		// Append the node
  		kNodes = append(kNodes, node)
  	}
  	return kNodes
  }
docs: // kRandomNodes is used to select up to k random nodes, excluding any nodes where
  // the filter function returns true. It is possible that less than k nodes are
  // returned.