toggle hide/unhide parent and children objects at once similarly to the outliner Shift+LMB function
Define and toggle a boolean property
From the other answer to link https://blender.stackexchange.com/a/147144/15543 it gives the object a hide_children property that if set hides the object and sets hide_children hence setting recursively for all children.
A checkbox to set the property is added to the text editor footer for testing.
import bpy
from bpy.props import BoolProperty


def hide_children(self, context):
    self.hide_set(self.hide_children)
    for o in self.children:
        o.hide_children = self.hide_children


bpy.types.Object.hide_children = BoolProperty(update=hide_children)


def draw(self, context):
    layout = self.layout
    ob = context.object
    layout.prop(ob, &quot;hide_children&quot;)


bpy.types.TEXT_HT_footer.append(draw)

Since the object can be found from context, can toggle the boolean value of the property using the window managers context toggle operator
After you have run the script above to register the property on the Object class
&gt;&gt;&gt; C.object.hide_children
False

&gt;&gt;&gt; C.object.hide_children = True

&gt;&gt;&gt; bpy.ops.wm.context_toggle(
context_toggle()
bpy.ops.wm.context_toggle(data_path=&quot;&quot;, module=&quot;&quot;)
Toggle a context value
&gt;&gt;&gt; bpy.ops.wm.context_toggle(data_path=&quot;object.hide_children&quot;)
{'FINISHED'}

If You do not run the script beforehand will get an error
# same as not running script (unregister the property)
&gt;&gt;&gt; del bpy.types.Object.hide_children 
&gt;&gt;&gt; bpy.ops.wm.context_toggle(data_path=&quot;object.hide_children&quot;)
context_path_validate error: context.object.hide_children not found (invalid keymap entry?)
{'PASS_THROUGH'}

Assign a shortcut.
With the script above run, and the property defined  can be set as a shortcut from context.

Image of Edit &gt; User Preferences &gt; Keymaps
Since once hidden an object cannot have context, and from the 3d view there is no way to select as a group AltH will unhide all previously hidden objects.
Note both the object (self) and context is passed to the update method could instead hide all objects and their children looping over context.selected_objects