def METHOD_NAME(course_or_org: FlagOverride):
    """
    Return flag objects from the requested override model instances.
    """
    # This dict is keyed by flag name, and contains dicts keyed by organization name, the contains
    # the final dict of metadata for a single course override that will be returned.
    flag_overrides = OrderedDict()
    # Note: We can't just get enabled records, because if a historical record is enabled but
    # the current record is disabled, we would not know this. We get all records, and mark
    # some overrides as disabled, and then later filter the disabled records.
    if course_or_org == FlagOverride.COURSE:
        override_key = "course_id"
        overrides_data = WaffleFlagCourseOverrideModel.objects.all().order_by(
            "waffle_flag", "course_id", "-change_date"
        )
    elif course_or_org == FlagOverride.ORG:
        override_key = "org"
        overrides_data = WaffleFlagOrgOverrideModel.objects.all().order_by(
            "waffle_flag", "org", "-change_date"
        )
    else:
        return {}
    for override in overrides_data:
        if course_or_org == FlagOverride.COURSE:
            override_match_val = str(override.course_id)
        elif course_or_org == FlagOverride.ORG:
            override_match_val = str(override.org)
        if override.enabled:
            override_fields = {
                "force": override.override_choice,
                "modified": str(override.change_date),
            }
        else:
            # The current record may be disabled, but later history might be enabled.
            # Disabled records are filtered elsewhere.
            override_fields = {"disabled": True}
        one_override = flag_overrides.setdefault(
            override.waffle_flag, OrderedDict()
        ).setdefault(
            override_match_val, OrderedDict()
        )
        # data is reverse ordered by date, so the first record is the current record
        if override_key not in one_override:
            one_override[override_key] = override_match_val
            one_override.update(override_fields)
        # data is reverse ordered by date, so the last record is the oldest record
        one_override["created"] = str(override.change_date)
    return flag_overrides