def processManifestForKey(manifest, manifest_key, installinfo,
                          parentcatalogs=None):
    """Processes keys in manifests to build the lists of items to install and
    remove.

    Can be recursive if manifests include other manifests.
    Probably doesn't handle circular manifest references well.

    manifest can be a path to a manifest file or a dictionary object.
    """
    if isinstance(manifest, basestring):
        munkicommon.display_debug1(
            "** Processing manifest %s for %s" %
            (os.path.basename(manifest), manifest_key))
        manifestdata = getManifestData(manifest)
    else:
        manifestdata = manifest
        manifest = 'embedded manifest'

    cataloglist = manifestdata.get('catalogs')
    if cataloglist:
        getCatalogs(cataloglist)
    elif parentcatalogs:
        cataloglist = parentcatalogs

    if not cataloglist:
        munkicommon.display_warning('Manifest %s has no catalogs', manifest)
        return

    nestedmanifests = manifestdata.get('included_manifests')
    if nestedmanifests:
        for item in nestedmanifests:
            try:
                nestedmanifestpath = getmanifest(item)
            except ManifestException:
                nestedmanifestpath = None
            if munkicommon.stopRequested():
                return {}
            if nestedmanifestpath:
                processManifestForKey(nestedmanifestpath, manifest_key,
                                      installinfo, cataloglist)

    conditionalitems = manifestdata.get('conditional_items')
    if conditionalitems:
        munkicommon.display_debug1(
            '** Processing conditional_items in %s', manifest)
        # conditionalitems should be an array of dicts
        # each dict has a predicate; the rest consists of the
        # same keys as a manifest
        for item in conditionalitems:
            try:
                predicate = item['condition']
            except (__HOLE__, KeyError):
                munkicommon.display_warning(
                    'Missing predicate for conditional_item %s', item)
                continue
            except BaseException:
                munkicommon.display_warning(
                    'Conditional item is malformed: %s', item)
                continue
            INFO_OBJECT['catalogs'] = cataloglist
            if predicateEvaluatesAsTrue(predicate):
                conditionalmanifest = item
                processManifestForKey(conditionalmanifest, manifest_key,
                                      installinfo, cataloglist)

    items = manifestdata.get(manifest_key)
    if items:
        for item in items:
            if munkicommon.stopRequested():
                return {}
            if manifest_key == 'managed_installs':
                dummy_result = processInstall(
                    item, cataloglist, installinfo)
            elif manifest_key == 'managed_updates':
                processManagedUpdate(item, cataloglist, installinfo)
            elif manifest_key == 'optional_installs':
                processOptionalInstall(item, cataloglist, installinfo)
            elif manifest_key == 'managed_uninstalls':
                dummy_result = processRemoval(
                    item, cataloglist, installinfo)
dataset/ETHPy150Open munki/munki/code/client/munkilib/updatecheck.py/processManifestForKey