code: func GetDeviceSessionsForDevAddr(p *redis.Pool, devAddr lorawan.DevAddr) ([]DeviceSession, error) {
  	var items []DeviceSession
  
  	c := p.Get()
  	defer c.Close()
  
  	devEUIs, err := redis.ByteSlices(c.Do("SMEMBERS", fmt.Sprintf(devAddrKeyTempl, devAddr)))
  	if err != nil {
  		if err == redis.ErrNil {
  			return items, nil
  		}
  		return nil, errors.Wrap(err, "get members error")
  	}
  
  	for _, b := range devEUIs {
  		var devEUI lorawan.EUI64
  		copy(devEUI[:], b)
  
  		s, err := GetDeviceSession(p, devEUI)
  		if err != nil {
  			// TODO: in case not found, remove the DevEUI from the list
  			log.WithFields(log.Fields{
  				"dev_addr": devAddr,
  				"dev_eui":  devEUI,
  			}).Warningf("get device-sessions for dev_addr error: %s", err)
  		}
  
  		// It is possible that the "main" device-session maps to a different
  		// devAddr as the PendingRejoinDeviceSession is set (using the devAddr
  		// that is used for the lookup).
  		if s.DevAddr == devAddr {
  			items = append(items, s)
  		}
  
  		// When a pending rejoin device-session context is set and it has
  		// the given devAddr, add it to the items list.
  		if s.PendingRejoinDeviceSession != nil && s.PendingRejoinDeviceSession.DevAddr == devAddr {
  			items = append(items, *s.PendingRejoinDeviceSession)
  		}
  	}
  
  	return items, nil
  }
docs: // GetDeviceSessionsForDevAddr returns a slice of device-sessions using the
  // given DevAddr. When no device-session is using the given DevAddr, this returns
  // an empty slice.