This is the refined targeting macro I am using at the moment. It works in and out of a group so long as you always set the tank as your focus when grouped.
I use this to cut out all the scrambling about when the tank dies in a group and you need to turn Growl back on and start using your pet to tank your way out of dying or Feigning Death and letting everyone else die 
/cleartarget [@target,dead]
/clearfocus [@focus,dead]
/petautocaston Growl
/petautocastoff [@focus,help,nodead,group] Growl
/cast Mend Pet
/assist [@focus,exists][@pet,exists]
/targetenemy [noharm]
/petassist
Explanation…
/cleartarget [@target,dead] - If the currently targeted unit is dead then: Clear your target.
/clearfocus [@focus,dead] - If the unit saved as your focus target is dead then: Clear your focus target.
/petautocaston Growl - Turn on pet skill autocast for Growl.
/petautocastoff [@focus,help,nodead,group] Growl - If the unit saved as your focus target is a friend and is not dead and you are in a group then: Turn off pet skill autocast for Growl.
/cast Mend Pet - Cast Mend Pet (Optional).
/assist [@focus,exists][@pet,exists] - If the unit saved as your focus target exists then: Set your target to the target of the currently targeted unit.
Else, if your pet exists then: Set your target to the target of the currently targeted unit.
/targetenemy [noharm] - If the currently targeted unit is not an enemy then: Target next visible enemy unit.
/petassist - Set Pet to Assist.
Using this macro when not in a group. It will cast Mend Pet and use /targetenemy [noharm] to target the nearest hostile unit and set your pet to assist.
Using this macro when in a group. You need to first set the tank as your focus unit.
As long as the focus (tank) is alive this will set Growl on autocast and then immediately turn it off again when it sees that you have a focus that is friendly and not dead and you are in a group.
It will then cast Mend Pet (optional) and assist either your focus if you have one or else it will assist your pet.
If neither of these have a target then it will use /targetenemy [noharm] to find a valid hostile unit and then set your pet to assist.
If you are in a group and the focus (tank) dies (I recommend setting up a weakaura to tell you this) and is not battle rezzed. Then all you need to do is press the button again…
This time it will clear your focus and turn autocast on Growl which this time will not be immediately turned off because you no longer have a focus. It will then cast Mend Pet and you will assist your pet by attacking his target (chances are he still has one). If your pet has no target then you will target the nearest hostile with /targetenemy [noharm].
You will have to remember to reset the tank as your focus when he is rezzed so that Growl autocast will turn back off.