code: def expandPath(self, path):
          
          iiPath = self.model().findItemAndIndexPath(path)
          for (item, index) in iiPath[1:]: # skip invisible root
              assert index.isValid(), "Sanity check: invalid index in path for item: {}".format(item)
              self.expand(index)
  
          leaf = iiPath[-1]
          return leaf
docs: Follows the path and expand all nodes along the way.
              Returns (item, index) tuple of the last node in the path (the leaf node). This can be
              reused e.g. to select it.