maven-helper.sh: move parent detection to a method

This reduces repeated code and makes it simpler to add more functions
that need to discern the parent GAV.
maven-helper.sh: add routine to get a GAV's parent