Creation of Node Setup with python, missing some commands
Cycles material nodes are accessible through the node_tree attribute of the material.

Example: get the node tree of the active material on the active object:

node_tree = bpy.context.object.active_material.node_tree


Add a node in the material / node editor

You have to know the bl_idname (a string) of the node you want to add. Then you can do:

node = node_tree.nodes.new(bl_idname)
# Example, add a "Diffuse BSDF" node:
node = node_tree.nodes.new("ShaderNodeBsdfDiffuse")


I think you can find all bl_idnames of Cycles nodes here: https://docs.blender.org/api/2.79/bpy.types.ShaderNode.html#bpy.types.ShaderNode

Remove a node in the material / node editor

# node is of type bpy.types.Node
node_tree.nodes.remove(node)


Link an input and an output

Assuming you have two nodes left_node and right_node.
output and input can be indices or strings.
For example, on a Diffuse BSDF node you can access the output by node.outputs["BSDF"] or by node.outputs[0].

node_tree.links.new(left_node.outputs[output], right_node.inputs[input])




Since you edited your question:
You should read the Blender API docs I linked above.
Cycles shader nodes inherit from bpy.types.Node.
You can get a specific node if you know its name: https://docs.blender.org/api/2.79/bpy.types.Node.html#bpy.types.Node.name

If you add the nodes via script, you already have a reference to the new node returned by the add() method (see above point "add a node").