def get_parent_unit(xblock):
 while xblock:
  xblock = xblock.get_parent()
  if (xblock is None):
   return None
  parent = xblock.get_parent()
  if (parent is None):
   return None
  if (parent.category == 'sequential'):
   return xblock

def get_parent_unit ( xblock ) : while xblock : xblock = xblock . get_parent ( ) if ( xblock is None ) : return None parent = xblock . get_parent ( ) if ( parent is None ) : return None if ( parent . category == 'sequential' ) : return xblock
find vertical that is a unit .