'Add selection rooted at item'

def _add_selection(self, item):

    outline = self._selection_poly(item)
    selection_item = QGraphicsPathItem(self)
    selection_item.setPos(self.contentsRect().topLeft())
    selection_item.setPen(make_pen(width=1, cosmetic=True))
    transform = self._transform
    path = transform.map(outline)
    margin = 4
    if item.node.is_leaf:
        ppath = QPainterPath()
        ppath.addRect(path.boundingRect().adjusted((- margin), (- margin), margin, margin))
    else:
        ppath = QPainterPath()
        ppath.addPolygon(path)
        ppath = path_outline(ppath, width=(margin * 2))
    selection_item.setPath(ppath)
    selection_item.unscaled_path = outline
    self._selection[item] = selection_item
