def compute_inherited_metadata(descriptor):
 if descriptor.has_children:
  parent_metadata = descriptor.xblock_kvs.inherited_settings.copy()
  for field in InheritanceMixin.fields.values():
   if field.is_set_on(descriptor):
    parent_metadata[field.name] = field.read_json(descriptor)
  for child in descriptor.get_children():
   inherit_metadata(child, parent_metadata)
   compute_inherited_metadata(child)

def compute_inherited_metadata ( descriptor ) : if descriptor . has_children : parent_metadata = descriptor . xblock_kvs . inherited_settings . copy ( ) for field in InheritanceMixin . fields . values ( ) : if field . is_set_on ( descriptor ) : parent_metadata [ field . name ] = field . read_json ( descriptor ) for child in descriptor . get_children ( ) : inherit_metadata ( child , parent_metadata ) compute_inherited_metadata ( child )
given a descriptor .