def _is_in_course_tree(block):
 ancestor = block.get_parent()
 while ((ancestor is not None) and (ancestor.location.category != 'course')):
  ancestor = ancestor.get_parent()
 return (ancestor is not None)

def _is_in_course_tree ( block ) : ancestor = block . get_parent ( ) while ( ( ancestor is not None ) and ( ancestor . location . category != 'course' ) ) : ancestor = ancestor . get_parent ( ) return ( ancestor is not None )
check that the xblock is in the course tree .