How to link an existing node group via Python script
import bpy

#you need to somehow specify the material(maybe loop through a few?..):
node_tree = bpy.data.materials['Material'].node_tree
# And a node group that you have in the file:
node_group_name = "NodeGroup"


nodes = node_tree.nodes
links = node_tree.links

# Let's at least check if some image node and output node exists 
# you might need a way to determine which ones to use if there are multiple 
image_node = output_node = None
node_group_exists = False
for node in nodes:    
    if node.type == 'TEX_IMAGE':
        image_node = node
    elif node.type == 'OUTPUT_MATERIAL':
        output_node = node
    elif node.type == 'GROUP': # in case the script was used already
        if node.node_tree.name == node_group_name:
            node_group_exists = True
            print('exists')
            group_node = node

if output_node and image_node:
    if node_group_name in bpy.data.node_groups and not node_group_exists:
        group_node=nodes.new("ShaderNodeGroup")
        # Creating the group is not enough, we need to specify data(node tree) for it
        group_node.node_tree = bpy.data.node_groups[node_group_name] 
        group_node.location = (0,0) #This is default anyway,  but in case you wish to move it

    links.new(image_node.outputs[0], group_node.inputs[0])
    links.new(group_node.outputs[0], output_node.inputs[0])