Avoid the unnecessary tail recursion since it can be converted into a loop directly in order to prevent potential stack overflow. It's a pretty straightforward conversion. Signed-off-by: Gao Xiang <hsiangkao@xxxxxxxxxxxxxxxxx>