def METHOD_NAME(
    indicators_or_incidents: Iterator[Union[IncidentType, IndicatorType]]
) -> Dict[str, List[str]]:
    """
    Iterates through incident/indicator types in the pack, builds a
    dict of {layoutID: [List of incident/indicator type IDs]}.
    where the list of the incident/indicator type IDs are the list of all the incident/indicator
    types whom layout field has corresponding ID to the layoutID field.
    Returns:
        (Dict[str, List[str]): Dict of {layoutID: [List of incident/indicator type IDs]}.
    """
    result: Dict[str, List[str]] = dict()
    for incident_or_indicator in indicators_or_incidents:
        layout_id = incident_or_indicator.get("layout")
        id_ = incident_or_indicator.get("id")
        if not layout_id or not id_:
            continue
        result[layout_id] = result.get(layout_id, []) + [id_]
    return result