An extension of E. Hopf’s maximum principle with an application to Riemannian geometry