'Return the item at `pos` that is an instance of the specified
type (`type_or_tuple`). If `buttons` (`Qt.MouseButtons`) is given
only return the item if it is the top level item that would
accept any of the buttons (`QGraphicsItem.acceptedMouseButtons`).'

def item_at(self, pos, type_or_tuple=None, buttons=0):

    rect = QRectF(pos, QSizeF(1, 1))
    items = self.items(rect)
    if buttons:
        items = itertools.dropwhile((lambda item: (not (item.acceptedMouseButtons() & buttons))), items)
        items = list(items)[:1]
    if type_or_tuple:
        items = [i for i in items if isinstance(i, type_or_tuple)]
    return (items[0] if items else None)
