private Context getParentContext(Element parent, Context context) {
        Set<InstanceName> instances = context.instances;
        Set<Environment> environments = context.environments;
        Set<RegionName> regions = context.regions;
        Set<CloudName> clouds = context.clouds;
        Tags tags = context.tags;
        if (instances.isEmpty())
            instances = getInstances(parent);
        if (environments.isEmpty())
            environments = getEnvironments(parent);
        if (regions.isEmpty())
            regions = getRegions(parent);
        if(clouds.isEmpty())
            clouds = getClouds(parent);
        if (tags.isEmpty())
            tags = getTags(parent);
        return Context.create(instances, environments, regions, clouds, tags);
    }
Handles overrides in a XML document according to the rules defined for multi-environment application packages.

Rules:

1. A directive specifying both environment and region will override a more generic directive specifying only one of them
2. Directives are inherited in child elements
3. When multiple XML elements with the same name is specified (i.e. when specifying search or docproc chains),
   the id attribute of the element is used together with the element name when applying directives

@author Ulf Lilleengen
config-application-package/src/main/java/com/yahoo/config/application/OverrideProcessor.java