fix build in recent Cython versions
simplify some code
optimise not so unlikely case of following single character tree nodes