private static Optional<String> mostSpecificAttribute(Element tag, String attributeName, boolean ignoreBlanks) {
        return Stream.iterate(tag, Objects::nonNull, Node::getParentNode)
                     .filter(Element.class::isInstance)
                     .map(Element.class::cast)
                     .flatMap(element -> stringAttribute(attributeName, element, ignoreBlanks).stream())
                     .findFirst();
    }
Returns the given attribute from the given tag or its closest ancestor with the attribute.
config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java