template_list is designed for CollectionProperties, which is like a 1-dimensional array of hashmaps (or in python lingo: a list of dicts).
It’s not really suitable for nesting like you desire.
I don’t think template_list is needed for what you want. You could just do something like:
import bpy
class HelloWorldPanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Children"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
layout = self.layout
start_ob = context.object
def child(ob, level=0):
row = layout.row()
for i in range(level*3):
row.separator() # FIXME
row.label(icon="FILE_PARENT" if level else "OBJECT_DATA")
row.prop(ob, "name", text="")
for child_ob in ob.children:
child(child_ob, level+1)
child(start_ob)
def register():
bpy.utils.register_class(HelloWorldPanel)
def unregister():
bpy.utils.unregister_class(HelloWorldPanel)
if __name__ == "__main__":
register()