code: def deleteItemAtIndex(self, itemIndex):
          
          if not itemIndex.isValid():
              logger.debug("No valid item selected for deletion (ignored).")
              return
  
          item = self.getItem(itemIndex, "<no item>")
          logger.debug("deleteItemAtIndex: removing {}".format(item))
  
          parentIndex = itemIndex.parent()
          parentItem = self.getItem(parentIndex, altItem=self.invisibleRootItem)
          row = itemIndex.row()
          self.beginRemoveRows(parentIndex, row, row)
          try:
              parentItem.removeChild(row)
          finally:
              self.endRemoveRows()
  
          logger.debug("deleteItemAtIndex completed")
docs: Removes the item at the itemIndex.
              The item's finalize method is called before removing so it can close its resources.