PointerProperty to node of material node tree I'm trying to register a PointerProperty to a node in a material's node tree.

After hours of trying a number of things, I suspect this is impossible and I think it's related to nodes not having their own bpy.data entry.

Basically I want to avoid having to repeatedly iterate over the nodes of a materials's node tree. So, once I found my node, I want to store in a PointerProperty.

I'm doing something similar with certain objects:

myobj = PointerProperty(name="My Obj", type=bpy.types.Object)


Which allows me to assign an object like so:

bpy.data.objects[0].MyPropGroup.myobj = bpy.data.objects[1]


And access the object like this:

bpy.data.objects[0].MyPropGroup.myobj.select = False
bpy.data.objects[0].MyPropGroup.myobj.hide_render = True


So far so good. 
I'd like to do the same with nodes, set the property like so

bpy.data.materials[0].MyPropGroup.mynode = bpy.data.materials[0].node_tree.nodes['MyNode']


And access it like this:

bpy.data.materials[0].MyPropGroup.mynode.mute = True


Unfortunately, all my attempts to register the pointer failed. I've tried these and a buch more.

mynode = PointerProperty(name="My Node", type=bpy.types.Node)
mynode = PointerProperty(name="My Node", type=bpy.types.NodeGroup)
mynode = PointerProperty(name="My Node", type=bpy.types.ShaderNode)
mynode = PointerProperty(name="My Node", type=bpy.types.ShaderNodeGroup)


All of them failed with

ValueError: bpy_struct "MyPropertyGroup" registration error: mynode could not register


It is acually a node group I am trying to point to, but would hope to do it for other node types as well.

I've succeeded registering

mynode = PointerProperty(name="My Node", type=bpy.types.ShaderNodeTree)


Which I then can assign the group node to. However I can't access it to manipulate node properties (like mute for instance). I can only access the group node tree of the group.

Any pointers - no pun intended - are appreciated. 
Although I could select the node group in question by name, instead of iterating over the node tree, I'd like to avoid it.
You cannot do this directly. With a PointerProperty you can only refer to a subclass of bpy.types.PropertyGroup or bpy.types.ID.
A Node is none of the above. Best way to solve this is to use a PointerProperty to point to the NodeTree (what is a subclass of bpy.types.ID) and use an additional bpy.props.StringProperty to select the specific node in that tree.
Note: Renaming the node will make the StringProperty Invalid.
Version 2.79
class MyPropertyGroup(bpy.types.PropertyGroup):
    material = bpy.props.PointerProperty(
        name=&quot;Material&quot;,
        type=bpy.types.Material,
    )
    node_name = bpy.props.StringProperty(
        default=&quot;&quot;,
        name=&quot;Node&quot;,
        description=&quot;Name of the node&quot;
    )
    @property
    def node(self):
        mat = self.material
        if mat:
            return mat.node_tree.nodes.get(self.node_name)


# draw function
def draw(self, context)
    layout = self.layout
    
    # NOTE: item is an instance of MyPropertyGroup

    layout.prop(item, &quot;material&quot;)
    node_selection_active = item.material is not None and item.material.use_nodes
    row = layout.row()
    row.enabled = node_selection_active
    if node_selection_active:
        row.prop_search(item, &quot;node_name&quot;, item.material.node_tree, &quot;nodes&quot;)
    else:
        row.prop(item, &quot;node_name&quot;)

Version 2.80+ (Use :instead of = for properties)
class MyPropertyGroup(bpy.types.PropertyGroup):
    material: bpy.props.PointerProperty(
        name=&quot;Material&quot;,
        type=bpy.types.Material,
    )
    node_name: bpy.props.StringProperty(
        default=&quot;&quot;,
        name=&quot;Node&quot;,
        description=&quot;Name of the node&quot;
    )
    @property
    def node(self):
        mat = self.material
        if mat:
            return mat.node_tree.nodes.get(self.node_name)


# draw function
def draw(self, context)
    layout = self.layout
    
    # NOTE: item is an instance of MyPropertyGroup

    layout.prop(item, &quot;material&quot;)
    node_selection_active = item.material is not None and item.material.use_nodes
    row = layout.row()
    row.enabled = node_selection_active
    if node_selection_active:
        row.prop_search(item, &quot;node_name&quot;, item.material.node_tree, &quot;nodes&quot;)
    else:
        row.prop(item, &quot;node_name&quot;)