def flatten_object_hierarchy(obj):
    """
    Flatten obj hierarchy.

    :param obj: a blender obj
    :return: a list containing the obj and all children.
    """

    def preorder(obj, objects):
        objects.append(obj)
        for c in obj.children:
            preorder(c, objects)

    objects = []
    preorder(obj, objects)

    return objects