Java runtime may limit recursion depth to 9K~32K => Using stack and loop instead