'Add a child group to a parent group in the given inventory.'

def _add_child(self, inv, parent_group, child_group):

    if (parent_group != 'all'):
        p_group = inv.setdefault(parent_group, {})
        if (not isinstance(p_group, dict)):
            inv[parent_group] = {'hosts': p_group}
            p_group = inv[parent_group]
        group_children = p_group.setdefault('children', [])
        if (child_group not in group_children):
            group_children.append(child_group)
    inv.setdefault(child_group, [])
