code: func mapAddressByPort(addr *v1.EndpointAddress, port v1.EndpointPort, ready bool, allAddrs map[addressKey]*v1.EndpointAddress, portToAddrReadyMap map[v1.EndpointPort]addressSet) *v1.EndpointAddress {
  	// use addressKey to distinguish between two endpoints that are identical addresses
  	// but may have come from different hosts, for attribution. For instance, Mesos
  	// assigns pods the node IP, but the pods are distinct.
  	key := addressKey{ip: addr.IP}
  	if addr.TargetRef != nil {
  		key.uid = addr.TargetRef.UID
  	}
  
  	// Accumulate the address. The full EndpointAddress structure is preserved for use when
  	// we rebuild the subsets so that the final TargetRef has all of the necessary data.
  	existingAddress := allAddrs[key]
  	if existingAddress == nil {
  		// Make a copy so we don't write to the
  		// input args of this function.
  		existingAddress = &v1.EndpointAddress{}
  		*existingAddress = *addr
  		allAddrs[key] = existingAddress
  	}
  
  	// Remember that this port maps to this address.
  	if _, found := portToAddrReadyMap[port]; !found {
  		portToAddrReadyMap[port] = addressSet{}
  	}
  	// if we have not yet recorded this port for this address, or if the previous
  	// state was ready, write the current ready state. not ready always trumps
  	// ready.
  	if wasReady, found := portToAddrReadyMap[port][existingAddress]; !found || wasReady {
  		portToAddrReadyMap[port][existingAddress] = ready
  	}
  	return existingAddress
  }
docs: // mapAddressByPort adds one address into a map by port, registering the address with a unique pointer, and preserving
  // any existing ready state.