after modifying optimize, pass all tests again

after modifying optimize, pass all tests again
optimize: don't recursive, loop with tasks instead.
add var declaration when toCode
deprecate modifying to optimize, use recursive call again.

deprecate modifying to optimize, use recursive call again.
because nonrecursive version is slow and use too many memory.