def METHOD_NAME(minion_id, key, minion):
    grains, pillar, addrs, mine = minion
    if key == "id":
        # Just paste in the minion ID
        return minion_id
    elif isinstance(key, dict):
        # Lookup the key in the dict
        for data_id, lookup in key.items():
            ref = {"pillar": pillar, "grain": grains, "mine": mine}[data_id]
            for k in _data_lookup(ref, lookup):
                if k:
                    return k
            return None
    elif key.startswith("sdb://"):
        # It's a Salt SDB url
        return salt["sdb.get"](key)
    elif re.match(r"^[0-9a-fA-F:./]+$", key):
        # It smells like a CIDR block
        try:
            net = ipaddress.ip_network(key, strict=True)
        except ValueError:
            log.error("%s is an invalid CIDR network", net)
            return None
        for addr in addrs[net.version]:
            if addr in net:
                return str(addr)
    else:
        # Take the addresses from the grains and filter them
        filters = {
            "global": lambda addr: addr.is_global
            if addr.version == 6
            else not addr.is_private,
            "public": lambda addr: not addr.is_private,
            "private": lambda addr: addr.is_private
            and not addr.is_loopback
            and not addr.is_link_local,
            "local": lambda addr: addr.is_loopback,
        }
        ip_vers = [4, 6]
        if key.startswith("ipv"):
            ip_vers = [int(key[3])]
            key = key[5:]
        for ip_ver in ip_vers:
            try:
                for addr in addrs[ip_ver]:
                    if filters[key](addr):
                        return str(addr)
            except KeyError:
                raise KeyError(
                    "Invalid filter {} specified in roster_order".format(key)
                )