Python implementation of the Stern-Brocot tree