def METHOD_NAME(
    libobject: JSON, key_callback: Optional[Set[str]] = None
) -> List[CachedObject]:
    """Converts an oparl object with embedded objects to multiple flat json objects"""
    externalized = []
    # sorted copies, thereby avoiding modification while iterating
    for key in sorted(libobject.keys()):
        # Skip the geojson object
        if key == "geojson":
            continue
        entry = libobject[key]
        if isinstance(entry, dict):
            if "id" not in entry:
                logger.warning(
                    f"Embedded object '{key}' in {libobject['id']} does not have an id,"
                    f" skipping: {entry}"
                )
                del libobject[key]
                continue
            if isinstance(key_callback, set):
                key_callback.add(key)
            entry["mst:backref"] = libobject["id"]
            externalized += METHOD_NAME(entry)
            libobject[key] = entry["id"]
        if isinstance(entry, list) and len(entry) > 0 and isinstance(entry[0], dict):
            if isinstance(key_callback, set):
                key_callback.add(key)
            for pos, entry in enumerate(entry):
                if "id" not in entry:
                    logger.warning(
                        f"Embedded object '{key}' in {libobject['id']} does not have an"
                        f" id, skipping: {entry}"
                    )
                    del libobject[key]
                    break
                entry["mst:backref"] = libobject["id"]
                entry["mst:backrefPosition"] = pos  # We need this for agenda items
                externalized += METHOD_NAME(entry)
                libobject[key][pos] = entry["id"]
    externalized.append(
        CachedObject(
            url=libobject["id"],
            data=libobject,
            oparl_type=libobject["type"].split("/")[-1],
        )
    )
    return externalized