Linking low- to high-mass young stellar objects with Herschel-HIFI observations of water