'Set class `class_` on the visible child no. index of `node`.
Do nothing if node has fewer children than `index`.'

def set_class_on_child(self, node, class_, index=0):

    children = [n for n in node if (not isinstance(n, nodes.Invisible))]
    try:
        child = children[index]
    except IndexError:
        return
    child['classes'].append(class_)
