def find_status_by_manifest_id(manifest, manifest_id):
    """
    Finds a status by manifestId in the given manifest.

    Args:
        manifest (dict): The manifest object containing statuses.
        manifest_id (str): The manifestId to search for.

    Returns:
        dict or None: The status object matching the manifestId, or None if not found.
    """
    if not manifest or "statuses" not in manifest:
        return None

    for status in manifest["statuses"]:
        # Check the top-level status
        if status.get("manifestId") == manifest_id:
            return status

        # Check nested items if the status has an 'items' list
        if "items" in status:
            for item in status["items"]:
                if item.get("manifestId") == manifest_id:
                    return item

    return None


def find_setting_by_manifest_id(manifest, manifest_id):
    """
    Finds a setting by its `manifestId` in the given manifest.
    Assumes that only one setting with the specified `manifestId` exists.

    The function searches for the `manifestId` in the following locations:
    1. At the root-level `settings`.
    2. Inside `settingGroups.settings`.
    3. Inside `settingLists[i].settinglistitems[j].items`.

    The search stops as soon as a match is found, returning the first matched object.

    Args:
        manifest (dict): The manifest to search.
        manifest_id (str): The `manifestId` to find.

    Returns:
        dict or None: The object with the matching `manifestId`, or `None` if not found.
    """
    # Check `settings` at the root level
    if "settings" in manifest:
        for s in manifest["settings"]:
            if s.get("manifestId") == manifest_id:
                return s

    # Check `settingGroups.settings`
    if "settingGroups" in manifest:
        for group in manifest["settingGroups"]:
            if "settings" in group:
                for s in group["settings"]:
                    if s.get("manifestId") == manifest_id:
                        return s

    # Check `settingLists[i].settinglistitems[j].items`
    if "settingLists" in manifest:
        for setting_list in manifest["settingLists"]:
            if "settinglistitems" in setting_list:
                for list_item in setting_list["settinglistitems"]:
                    if "items" in list_item:
                        for item in list_item["items"]:
                            if item.get("manifestId") == manifest_id:
                                return item

    # Return None if no match is found
    return None
