def cursorAtSpaceEnd(block):
            cursor = QTextCursor(block)
            cursor.setPosition(block.position() + len(blockIndentation(block)))
            return cursor
def kth(root, k):
    if k < size(root.left):
        return kth(root.left, k)
    elif k > size(root.left):
        return kth(root.right, k - size(root.left) - 1)
    return root.key