def create_children(store, parent, category, load_factor):
 created_count = 0
 for child_index in range(load_factor):
  child_object = ItemFactory.create(parent_location=parent.location, category=category, display_name=u'{} {} {}'.format(category, child_index, time.clock()), modulestore=store, publish_item=True, start=datetime(2015, 3, 1, tzinfo=UTC))
  created_count += 1
  if (category in COURSE_CHILD_STRUCTURE):
   created_count += create_children(store, child_object, COURSE_CHILD_STRUCTURE[category], load_factor)
 return created_count

def create_children ( store , parent , category , load_factor ) : created_count = 0 for child_index in range ( load_factor ) : child_object = ItemFactory . create ( parent_location = parent . location , category = category , display_name = u'{} {} {}' . format ( category , child_index , time . clock ( ) ) , modulestore = store , publish_item = True , start = datetime ( 2015 , 3 , 1 , tzinfo = UTC ) ) created_count += 1 if ( category in COURSE_CHILD_STRUCTURE ) : created_count += create_children ( store , child_object , COURSE_CHILD_STRUCTURE [ category ] , load_factor ) return created_count
create load_factor children within the given parent; recursively call to insert children when appropriate .