code: def get_item_children(item):
      children = [item.child(index) for index in range(item.childCount())]
      for child in children[:]:
          others = get_item_children(child)
          if others is not None:
              children += others
      return sorted(children, key=lambda child: child.line)