def find_tx_extra_field_by_type(extra_fields, msg, idx=0):
    """
    Finds given message type in the extra array, or returns None if not found
    :param extra_fields:
    :param msg:
    :param idx:
    :return:
    """
    cur_idx = 0
    for x in extra_fields:
        if isinstance(x, msg):
            if cur_idx == idx:
                return x
            cur_idx += 1
    return None