Delete parent object hierarchy in code
Your own solution probably works fine in your case, but the general case where the hierarchy is a bit more nested (children of children) might still deserve a solution.

perhaps something recursive:

import bpy

def delete_hierarchy(obj):
    names = set([obj.name])

    # recursion
    def get_child_names(obj):
        for child in obj.children:
            names.add(child.name)
            if child.children:
                get_child_names(child)

    get_child_names(obj)

    print(names)
    objects = bpy.data.objects
    [setattr(objects[n], 'select', True) for n in names]

    bpy.ops.object.delete()

delete_hierarchy(bpy.context.active_object)


This function assumes no objects are currently selected, and accumulates the names of the hierarchy starting with the main object ( i used active_object, but you can pass any object reference there ). Then it selects all the found names, then runs the object_delete operator.