<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def layout_item(layout, item_id, item_class):
 """Fetch a specific item according to its type in a layout. There's some sip casting conversion issues with QgsLayout::itemById. Don't use it, and use this function instead. See https://github.com/inasafe/inasafe/issues/4271 :param layout: The layout to look in. :type layout: QgsLayout :param item_id: The ID of the item to look for. :type item_id: basestring :param item_class: The expected class name. :type item_class: cls :return: The layout item, inherited class of QgsLayoutItem. """

    item = layout.itemById(item_id)
    if item is None:
        # no match!
        return item

    if issubclass(item_class, QgsLayoutMultiFrame):
        # finding a multiframe by frame id
        frame = sip.cast(item, QgsLayoutFrame)
        multi_frame = frame.multiFrame()
        return sip.cast(multi_frame, item_class)
    else:
        # force sip to correctly cast item to required type
        return sip.cast(item, item_class)