code: func WaitForLeader(ctx context.Context, n *Node) error {
  	_, err := n.Leader()
  	if err == nil {
  		return nil
  	}
  	ticker := time.NewTicker(50 * time.Millisecond)
  	defer ticker.Stop()
  	for err != nil {
  		select {
  		case <-ticker.C:
  		case <-ctx.Done():
  			return ctx.Err()
  		}
  		_, err = n.Leader()
  	}
  	return nil
  }
docs: // WaitForLeader waits until node observe some leader in cluster. It returns
  // error if ctx was cancelled before leader appeared.