preventing python maximum recursion depth in order bubbles + test