How to check if Node connected to another node input in Python
To answer comment


  What I want is to test if any node is connected to the alpha channel
  of the Principled Shader. If not, I would create a White RGB node and
  connect it.


import bpy
context = bpy.context
ob = context.object
# all node based materials on object
mats = set(s.material for s in ob.material_slots
       if s.material and s.material.use_nodes)
for m in mats:
    nodes = m.node_tree.nodes
    bsdfnodes = [n for n in nodes 
            if isinstance(n, bpy.types.ShaderNodeBsdfPrincipled)]
    for n in bsdfnodes:
        if not n.inputs[18].links:
            rgb = nodes.new("ShaderNodeRGB")
            rgb.outputs[0].default_value = (1, 1, 1, 1)
            m.node_tree.links.new(n.inputs[18], rgb.outputs[0])