ENH reduce amount of boiler code using standard operation in tree/_utils

Inspired from the last @jnothman pull request, I simplify a bit sklearn/tree/_utils.pyx using standard tools.