I'm looking for an algorithm that can generate optimized syntactically valid variable names (for javascript in this case) without collisions. So as general rule I would want something that generated aa, ab, ac .... az, a1, a2, a3, a4, a5, a6, a7, a8, a9ba, bb, bc.... bz, b1....zz...z9...aaa,aab....it does not generate them at once, it does it going through a code base and does it whenever certain conditions are found (This will actually be done using a gulp plugin so this doesn't need to take walking the AST into account). Therefore it needs to be able to know what the current variable to be generated should be based on what the last variable was. So that if the last variable is aaz it would know to do aa1 and if the last variable is azz it would know to do az1 and so forth. 
Algorithm for optimized variable generation without collisions?
algorithms;code generation