private Optional<Node> tryAllocateNode(Node node,
                                           List<Node> hosts,
                                           Map<Node, AllocationResources> availableResources,
                                           Map<Node, List<Allocation>> containedAllocations) {
        AllocationResources requiredNodeResources = AllocationResources.from(node);
        for (var host : hosts) {
            var availableHostResources = availableResources.get(host);
            if (violatesParentHostPolicy(node, host, containedAllocations)) {
                continue;
            }
            if (availableHostResources.satisfies(requiredNodeResources)) {
                availableResources.put(host, availableHostResources.subtract(requiredNodeResources));
                if (node.allocation().isPresent()) {
                    containedAllocations.get(host).add(node.allocation().get());
                }
                return Optional.of(host);
            }
        }

        return Optional.empty();
    }
Returns the parent to which the node was allocated, if it was successfully allocated.
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java