Fixed #23758 -- Added recursion limit and alphabet extension

Refactored `bump_prefix` method to avoid infinite loop and allow more
than 5 subquires by extenting the alphabet to use multi letters.