def get_tex_nodes(m):
    """Returns Image Texture node, creates one if it doesn't exist."""
    nt = m.node_tree
    m.cycles.displacement_method = "DISPLACEMENT"

    # Check whether the Image Texture node has been added
    diff_img_node = nt.nodes.get("Image Texture")
    rough_img_node = nt.nodes.get("Image Texture.001")
    disp_img_node = nt.nodes.get("Image Texture.002")

    if diff_img_node is None:
        # Create new node for linking images
        nt.nodes.new("ShaderNodeTexImage")
        nt.nodes.new("ShaderNodeTexImage")
        nt.nodes.new("ShaderNodeTexImage")
        nt.nodes.new("ShaderNodeMapRange")
        diff_img_node = nt.nodes.get("Image Texture")
        rough_img_node = nt.nodes.get("Image Texture.001")
        rough_scaling_node = nt.nodes.get("Map Range")
        disp_img_node = nt.nodes.get("Image Texture.002")

        # Link to main node
        bsdf_node = nt.nodes.get("Principled BSDF")
        nt.links.new(
            diff_img_node.outputs.get("Color"), bsdf_node.inputs.get("Base Color")
        )
        nt.links.new(
            rough_img_node.outputs.get("Color"), rough_scaling_node.inputs.get("Value")
        )
        nt.links.new(
            rough_scaling_node.outputs.get("Result"), bsdf_node.inputs.get("Roughness")
        )

        # Set up nodes for mixing in color
        disp_node = nt.nodes.new("ShaderNodeDisplacement")
        disp_node.space = "WORLD"
        disp_node.inputs.get("Scale").default_value = 0.05
        out_node = nt.nodes.get("Material Output")
        nt.links.new(disp_img_node.outputs.get("Color"), disp_node.inputs.get("Height"))
        nt.links.new(
            disp_node.outputs.get("Displacement"), out_node.inputs.get("Displacement")
        )

    return diff_img_node, rough_img_node, disp_img_node
Returns Image Texture node, creates one if it doesn't exist.
infinigen/assets/objects/trees/utils/materials.py