insertOrderedList: remove [].forEach and use while instead

Since manipulating the child nodes in [].forEach is dangerous, I replaced them with while loop.