def udid_to_scsi_mapping(vios_w, udid, lpar_id, ignore_orphan=True):
    """Finds the SCSI mapping (if any) for a given backing storage udid.

    This is a helper method that will parse through a given VIOS wrapper
    (retrieved with pypowervm.const.XAG.VIO_SMAP) and will find the client
    SCSI mapping for a given backing storage element (LU, PV, LV, VOpt).

    :param vios_w: The Virtual I/O Server wrapper.  Should have the Storage
                   and SCSI mapping XAG associated with it.
    :param udid: The volume's udid.
    :param lpar_id: The LPARs 'short' id.
    :param ignore_orphan: (Optional, Default: True) If set to True, any orphan
                          SCSI mappings (those with no client adapter) will be
                          ignored.
    :return: The first matching SCSI mapping (or None).
    """
    for scsi_map in vios_w.scsi_mappings:
        if not scsi_map.backing_storage:
            continue
        if not scsi_map.client_adapter and ignore_orphan:
            continue
        if lpar_id != scsi_map.server_adapter.lpar_id:
            continue
        if scsi_map.backing_storage.udid == udid:
            return scsi_map
    return None
