def tree_to_array(cls, tree, region_number_to_name_bidict=None):
         
     if region_number_to_name_bidict is None:
         if tree.region_number_to_name_bidict is not None:
             region_number_to_name_bidict = copy.deepcopy( tree.region_number_to_name_bidict ) 
         else:
             region_number_to_name_bidict = AutoRegionToIntMapTable()
             
     
     vertices= [ None ] * ( len(tree) + 1 )
     connectivity = [] 
     section_types = []
     section_index = SectionIndexerDF(morph=tree, offset=1).dict
     section_index[tree.getDummySection()] = 0 
     
     
     for seg in tree._every_section():
         index = section_index[seg]
         
         # Store the vertices:
         vertices[ index ] = seg.getDistalNPA4()
         
         # Store the link to the parent:
         if not seg.isDummySection():
             connectivity.append( (index,section_index[seg.parent]  ) )
         
         # Store the type:
         if not seg.isDummySection():
             region = seg.region
             if region:
                 section_types.append( region_number_to_name_bidict.regionNameToInt(region.name) )
             else:
                 section_types.append( 0 )
              
     m = MorphologyArray(vertices=vertices, connectivity=connectivity, dummy_vertex_index=0, section_types=section_types, )
     return m