private static void DeleteNoInits(JsVar node, int min, string name)
        {
            // walk backwards from the end of the list down to (and including) the minimum index
            for (int ndx = node.Count - 1; ndx >= min; --ndx)
            {
                var varDecl = node[ndx];

                // if the name matches and there is no initializer...
                if (string.CompareOrdinal(varDecl.Identifier, name) == 0
                    && varDecl.Initializer == null)
                {
                    // ...remove it from the list and from the field's declarations
                    node.RemoveAt(ndx);
                    varDecl.VariableField.Declarations.Remove(varDecl);
                }
            }
        }
        public override void Visit(JsVar node)
        {
            if (node != null)
            {
                // first we want to weed out duplicates that don't have initializers
                // var a=1, a=2 is okay, but var a, a=2 and var a=2, a should both be just var a=2,
                // and var a, a should just be var a
                if (m_parser.Settings.IsModificationAllowed(JsTreeModifications.RemoveDuplicateVar))
                {
                    // first we want to weed out duplicates that don't have initializers
                    // var a=1, a=2 is okay, but var a, a=2 and var a=2, a should both be just var a=2,
                    // and var a, a should just be var a
                    int ndx = 0;
                    while (ndx < node.Count)
                    {
                        string thisName = node[ndx].Identifier;

                        // handle differently if we have an initializer or not
                        if (node[ndx].Initializer != null)
                        {
                            // the current vardecl has an initializer, so we want to delete any other
                            // vardecls of the same name in the rest of the list with no initializer
                            // and move on to the next item afterwards
                            DeleteNoInits(node, ++ndx, thisName);
                        }
                        else
                        {
                            // this vardecl has no initializer, so we can delete it if there is ANY
                            // other vardecl with the same name (whether or not it has an initializer)
                            if (VarDeclExists(node, ndx + 1, thisName))
                            {
                                // don't increment the index; we just deleted the current item,
                                // so the next item just slid into this position
                                node[ndx].VariableField.Declarations.Remove(node[ndx]);
                                node.RemoveAt(ndx);
                            }
                            else
                            {
                                // nope -- it's the only one. Move on to the next
                                ++ndx;
                            }
                        }
                    }
                }

                // recurse the analyze
                base.Visit(node);
            }
        }