'Set the number of blanks between a comment and class or func definition.
Class and function definitions have leading comments as children of the
classdef and functdef nodes.
Arguments:
node: (pytree.Node) The classdef or funcdef node.
Returns:
The index of the first child past the comment nodes.'

def _SetBlankLinesBetweenCommentAndClassFunc(self, node):

    index = 0
    while pytree_utils.IsCommentStatement(node.children[index]):
        self.Visit(node.children[index].children[0])
        if (not self.last_was_decorator):
            self._SetNumNewlines(node.children[index].children[0], _ONE_BLANK_LINE)
        index += 1
    if (index and ((node.children[index].lineno - 1) == node.children[(index - 1)].children[0].lineno)):
        self._SetNumNewlines(node.children[index], _NO_BLANK_LINES)
    else:
        if ((self.last_comment_lineno + 1) == node.children[index].lineno):
            num_newlines = _NO_BLANK_LINES
        else:
            num_newlines = self._GetNumNewlines(node)
        self._SetNumNewlines(node.children[index], num_newlines)
    return index
