private static Optional<String> resolveAndVerify(Context context, HostName hostname, IpAddresses.Stack stack, Version version, List<String> unusedIps) {
            if (context.hasIpNotInDns(version)) {
                List<String> candidates = unusedIps.stream()
                                                   .filter(a -> IP.Version.fromIpAddress(a).equals(version))
                                                   .toList();
                if (candidates.size() != 1) {
                    throw new IllegalStateException("Unable to find a unique child IP address of " + hostname + ": Found " + candidates);
                }
                return candidates.stream().findFirst();
            }

            Optional<String> address = resolveOptional(hostname.value(), context.resolver(), version.toForwardRecordType());
            if (stack.supports(version) && address.isEmpty())
                throw new IllegalArgumentException(stack.description + " hostname " + hostname.value() + " did not resolve to an " + version + " address");
            if (!stack.supports(version) && address.isPresent())
                throw new IllegalArgumentException(stack.description + " hostname " + hostname.value() + " has an " + version + " address: " + address.get());

            return address;
        }
Allocate an IPv4 address. A successful allocation is guaranteed to have an IPv4 address.

@param ipAddress Unassigned IPv4 address
@param resolver DNS name resolver to use
@return An allocation containing 1 IPv4 address.
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java