def find_staff_lock_source(xblock):
 if xblock.fields['visible_to_staff_only'].is_set_on(xblock):
  return xblock
 if (xblock.category == 'chapter'):
  return None
 parent_location = modulestore().get_parent_location(xblock.location, revision=ModuleStoreEnum.RevisionOption.draft_preferred)
 if (not parent_location):
  return None
 parent = modulestore().get_item(parent_location)
 return find_staff_lock_source(parent)

def find_staff_lock_source ( xblock ) : if xblock . fields [ 'visible_to_staff_only' ] . is_set_on ( xblock ) : return xblock if ( xblock . category == 'chapter' ) : return None parent_location = modulestore ( ) . get_parent_location ( xblock . location , revision = ModuleStoreEnum . RevisionOption . draft_preferred ) if ( not parent_location ) : return None parent = modulestore ( ) . get_item ( parent_location ) return find_staff_lock_source ( parent )
returns the xblock responsible for setting this xblocks staff lock .