def __combineVarStatements(node):
    """Top level method called to optimize a script node"""
    
    if len(node.scope.declared) == 0:
        return
    
    firstVar = __findFirstVarStatement(node)
    
    # Special case, when a node has variables, but no valid "var" block to hold them
    # This happens in cases where there is a for-loop which contains a "var", but
    # there are no other variable declarations anywhere. In this case we are not able
    # to optimize the code further and just exit at this point
    
    # Only size-saving when there are multiple for-in loops, but no other var statement or first
    # "free" var declaration is after for-loops.
    if not firstVar:
        firstVar = Node.Node(None, "var")
        node.insert(0, firstVar)
    
    __patchVarStatements(node, firstVar)
    __cleanFirst(firstVar)
    
    # Remove unused "var"
    if len(firstVar) == 0:
        firstVar.parent.remove(firstVar)

    else:
        # When there is a classical for loop immediately after our 
        # first var statement, then we try to move the var declaration
        # into there as a setup expression
    
        firstVarParent = firstVar.parent
        firstVarPos = firstVarParent.index(firstVar)
        if firstVarPos+1 > len(firstVarParent):
            possibleForStatement = firstVarParent[firstVarPos+1]
            if possibleForStatement.type == "for" and not hasattr(possibleForStatement, "setup"):
                possibleForStatement.append(firstVar, "setup")
dataset/ETHPy150Open zynga/jasy/jasy/js/optimize/CombineDeclarations.py/__combineVarStatements/swapped operands of `>`