def METHOD_NAME(context, context_member, property_type):
    space = context.space_data
    if space is None or isinstance(space, bpy.types.SpaceProperties):
        pin_id = space.pin_id
    else:
        pin_id = None
    if pin_id and isinstance(pin_id, property_type):
        rna_item = pin_id
        context_member = "space_data.pin_id"
    else:
        rna_item = context.path_resolve(context_member)
    return rna_item, context_member