def METHOD_NAME(codenames: dict) -> dict:
    """
    If `codenames` will approach `werkzeug.Response.max_cookie_size` once
    serialized, incrementally pop off the oldest codename until the remaining
    (newer) ones will fit.
    """
    serialized = json.dumps(codenames).encode()
    if len(codenames) > 1 and len(serialized) > 4000:  # werkzeug.Response.max_cookie_size = 4093
        if current_app:
            current_app.logger.warn(
                f"Popping oldest of {len(codenames)} "
                f"codenames ({len(serialized)} bytes) to "
                f"fit within maximum cookie size"
            )
        del codenames[list(codenames)[0]]  # FIFO
        return METHOD_NAME(codenames)
    return codenames