user: Show practical ways to work with Poll Function in a Blender add-on or script – include code.

assistant: The [`NodeTree.poll`](#bpy.types.NodeTree.poll "bpy.types.NodeTree.poll") function determines if a node tree is visible
in the given context (similar to how [`Panel.poll`](bpy.types.Panel.html#bpy.types.Panel.poll "bpy.types.Panel.poll")
and [`Menu.poll`](bpy.types.Menu.html#bpy.types.Menu.poll "bpy.types.Menu.poll") define visibility). If it returns False,
the node tree type will not be selectable in the node editor.

A typical condition for shader nodes would be to check the active render engine
of the scene and only show nodes of the renderer they are designed for.

```
import bpy

class CyclesNodeTree(bpy.types.NodeTree):
    """ This operator is only visible when Cycles is the selected render engine"""
    bl_label = "Cycles Node Tree"
    bl_icon = 'NONE'

    @classmethod
    def poll(cls, context):
        return context.scene.render.engine == 'CYCLES'

bpy.utils.register_class(CyclesNodeTree)
```

base classes — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct"), [`ID`](bpy.types.ID.html#bpy.types.ID "bpy.types.ID")

subclasses —
[`CompositorNodeTree`](bpy.types.CompositorNodeTree.html#bpy.types.CompositorNodeTree "bpy.types.CompositorNodeTree"), [`GeometryNodeTree`](bpy.types.GeometryNodeTree.html#bpy.types.GeometryNodeTree "bpy.types.GeometryNodeTree"), [`ShaderNodeTree`](bpy.types.ShaderNodeTree.html#bpy.types.ShaderNodeTree "bpy.types.ShaderNodeTree"), [`TextureNodeTree`](bpy.types.TextureNodeTree.html#bpy.types.TextureNodeTree "bpy.types.TextureNodeTree")

*class* bpy.types.NodeTree(*ID*)
:   Node tree consisting of linked nodes used for shading, textures and compositing

    animation_data
    :   Animation data for this data-block

        Type:
        :   [`AnimData`](bpy.types.AnimData.html#bpy.types.AnimData "bpy.types.AnimData"), (readonly)

    annotation
    :   Annotation data

        Type:
        :   [`Annotation`](bpy.types.Annotation.html#bpy.types.Annotation "bpy.types.Annotation")

    bl_description
    :   Type:
        :   string, default “”, (never None)

    bl_icon
    :   The node tree icon

        Type:
        :   enum in [Icon Items](bpy_types_enum_items/icon_items.html#rna-enum-icon-items), default `'NODETREE'`

    bl_idname
    :   Type:
        :   string, default “”, (never None)

    bl_label
    :   The node tree label

        Type:
        :   string, default “”, (never None)

    bl_use_group_interface
    :   Determines the visibility of some UI elements related to node groups

        Type:
        :   boolean, default True

    color_tag
    :   Color tag of the node group which influences the header color

        - `NONE`
          None – Default color tag for new nodes and node groups.
        - `ATTRIBUTE`
          Attribute.
        - `COLOR`
          Color.
        - `CONVERTER`
          Converter.
        - `DISTORT`
          Distort.
        - `FILTER`
          Filter.
        - `GEOMETRY`
          Geometry.
        - `INPUT`
          Input.
        - `MATTE`
          Matte.
        - `OUTPUT`
          Output.
        - `SCRIPT`
          Script.
        - `SHADER`
          Shader.
        - `TEXTURE`
          Texture.
        - `VECTOR`
          Vector.
        - `PATTERN`
          Pattern.
        - `INTERFACE`
          Interface.
        - `GROUP`
          Group.

        Type:
        :   enum in [`'NONE'`, `'ATTRIBUTE'`, `'COLOR'`, `'CONVERTER'`, `'DISTORT'`, `'FILTER'`, `'GEOMETRY'`, `'INPUT'`, `'MATTE'`, `'OUTPUT'`, `'SCRIPT'`, `'SHADER'`, `'TEXTURE'`, `'VECTOR'`, `'PATTERN'`, `'INTERFACE'`, `'GROUP'`], default `'NONE'`

    default_group_node_width
    :   The width for newly created group nodes

        Type:
        :   int in [60, 700], default 140

    description
    :   Description of the node tree

        Type:
        :   string, default “”, (never None)

    interface
    :   Interface declaration for this node tree

        Type:
        :   [`NodeTreeInterface`](bpy.types.NodeTreeInterface.html#bpy.types.NodeTreeInterface "bpy.types.NodeTreeInterface"), (readonly)

    links
    :   Type:
        :   [`NodeLinks`](bpy.types.NodeLinks.html#bpy.types.NodeLinks "bpy.types.NodeLinks") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`NodeLink`](bpy.types.NodeLink.html#bpy.types.NodeLink "bpy.types.NodeLink"), (readonly)

    nodes
    :   Type:
        :   [`Nodes`](bpy.types.Nodes.html#bpy.types.Nodes "bpy.types.Nodes") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`Node`](bpy.types.Node.html#bpy.types.Node "bpy.types.Node"), (readonly)

    type
    :   Node Tree type (deprecated, bl_idname is the actual node tree type identifier)

        - `UNDEFINED`
          Undefined – Undefined type of nodes (can happen e.g. when a linked node tree goes missing).
        - `CUSTOM`
          Custom – Custom nodes.
        - `SHADER`
          Shader – Shader nodes.
        - `TEXTURE`
          Texture – Texture nodes.
        - `COMPOSITING`
          Compositing – Compositing nodes.
        - `GEOMETRY`
          Geometry – Geometry nodes.

        Type:
        :   enum in [`'UNDEFINED'`, `'CUSTOM'`, `'SHADER'`, `'TEXTURE'`, `'COMPOSITING'`, `'GEOMETRY'`], default `'SHADER'`, (readonly)

    view_center
    :   The current location (offset) of the view for this Node Tree

        Type:
        :   [`mathutils.Vector`](mathutils.html#mathutils.Vector "mathutils.Vector") of 2 items in [-inf, inf], default (0.0, 0.0), (readonly)

    interface_update(*context*)
    :   Updated node group interface

    contains_tree(*sub_tree*)
    :   Check if the node tree contains another. Used to avoid creating recursive node groups.

        Parameters:
        :   **sub_tree** ([`NodeTree`](#bpy.types.NodeTree "bpy.types.NodeTree"), (never None)) – Node Tree, Node tree for recursive check

        Returns:
        :   contained

        Return type:
        :   boolean

    *classmethod* poll(*context*)
    :   Check visibility in the editor

        Return type:
        :   boolean

    update()
    :   Update on editor changes

    *classmethod* get_from_context(*context*)
    :   Get a node tree from the context

        Returns:
        :   `result_1`, Active node tree from context, [`NodeTree`](#bpy.types.NodeTree "bpy.types.NodeTree")

            `result_2`, ID data-block that owns the node tree, [`ID`](bpy.types.ID.html#bpy.types.ID "bpy.types.ID")

            `result_3`, Original ID data-block selected from the context, [`ID`](bpy.types.ID.html#bpy.types.ID "bpy.types.ID")

        Return type:
        :   ([`NodeTree`](#bpy.types.NodeTree "bpy.types.NodeTree"), [`ID`](bpy.types.ID.html#bpy.types.ID "bpy.types.ID"), [`ID`](bpy.types.ID.html#bpy.types.ID "bpy.types.ID"))

    *classmethod* valid_socket_type(*idname*)
    :   Check if the socket type is valid for the node tree

        Parameters:
        :   **idname** (*string**,* *(**never None**)*) – Socket Type, Identifier of the socket type

        Return type:
        :   boolean

    debug_lazy_function_graph()
    :   Get the internal lazy-function graph for this node tree

        Returns:
        :   Dot Graph, Graph in dot format

        Return type:
        :   string

    *classmethod* bl_rna_get_subclass(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The RNA type or default when not found.

        Return type:
        :   [`bpy.types.Struct`](bpy.types.Struct.html#bpy.types.Struct "bpy.types.Struct") subclass

    *classmethod* bl_rna_get_subclass_py(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The class or default when not found.

        Return type:
        :   [type](#bpy.types.NodeTree.type "bpy.types.NodeTree.type")

### Inherited Properties

|  |  |
| --- | --- |
| - [`bpy_struct.id_data`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.id_data "bpy.types.bpy_struct.id_data") - [`ID.name`](bpy.types.ID.html#bpy.types.ID.name "bpy.types.ID.name") - [`ID.name_full`](bpy.types.ID.html#bpy.types.ID.name_full "bpy.types.ID.name_full") - [`ID.id_type`](bpy.types.ID.html#bpy.types.ID.id_type "bpy.types.ID.id_type") - [`ID.session_uid`](bpy.types.ID.html#bpy.types.ID.session_uid "bpy.types.ID.session_uid") - [`ID.is_evaluated`](bpy.types.ID.html#bpy.types.ID.is_evaluated "bpy.types.ID.is_evaluated") - [`ID.original`](bpy.types.ID.html#bpy.types.ID.original "bpy.types.ID.original") - [`ID.users`](bpy.types.ID.html#bpy.types.ID.users "bpy.types.ID.users") - [`ID.use_fake_user`](bpy.types.ID.html#bpy.types.ID.use_fake_user "bpy.types.ID.use_fake_user") - [`ID.use_extra_user`](bpy.types.ID.html#bpy.types.ID.use_extra_user "bpy.types.ID.use_extra_user") - [`ID.is_embedded_data`](bpy.types.ID.html#bpy.types.ID.is_embedded_data "bpy.types.ID.is_embedded_data") | - [`ID.is_linked_packed`](bpy.types.ID.html#bpy.types.ID.is_linked_packed "bpy.types.ID.is_linked_packed") - [`ID.is_missing`](bpy.types.ID.html#bpy.types.ID.is_missing "bpy.types.ID.is_missing") - [`ID.is_runtime_data`](bpy.types.ID.html#bpy.types.ID.is_runtime_data "bpy.types.ID.is_runtime_data") - [`ID.is_editable`](bpy.types.ID.html#bpy.types.ID.is_editable "bpy.types.ID.is_editable") - [`ID.tag`](bpy.types.ID.html#bpy.types.ID.tag "bpy.types.ID.tag") - [`ID.is_library_indirect`](bpy.types.ID.html#bpy.types.ID.is_library_indirect "bpy.types.ID.is_library_indirect") - [`ID.library`](bpy.types.ID.html#bpy.types.ID.library "bpy.types.ID.library") - [`ID.library_weak_reference`](bpy.types.ID.html#bpy.types.ID.library_weak_reference "bpy.types.ID.library_weak_reference") - [`ID.asset_data`](bpy.types.ID.html#bpy.types.ID.asset_data "bpy.types.ID.asset_data") - [`ID.override_library`](bpy.types.ID.html#bpy.types.ID.override_library "bpy.types.ID.override_library") - [`ID.preview`](bpy.types.ID.html#bpy.types.ID.preview "bpy.types.ID.preview") |

### Inherited Functions

|  |  |
| --- | --- |
| - [`bpy_struct.as_pointer`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.as_pointer "bpy.types.bpy_struct.as_pointer") - [`bpy_struct.driver_add`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.driver_add "bpy.types.bpy_struct.driver_add") - [`bpy_struct.driver_remove`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.driver_remove "bpy.types.bpy_struct.driver_remove") - [`bpy_struct.get`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.get "bpy.types.bpy_struct.get") - [`bpy_struct.id_properties_clear`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.id_properties_clear "bpy.types.bpy_struct.id_properties_clear") - [`bpy_struct.id_properties_ensure`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.id_properties_ensure "bpy.types.bpy_struct.id_properties_ensure") - [`bpy_struct.id_properties_ui`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.id_properties_ui "bpy.types.bpy_struct.id_properties_ui") - [`bpy_struct.is_property_hidden`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.is_property_hidden "bpy.types.bpy_struct.is_property_hidden") - [`bpy_struct.is_property_overridable_library`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.is_property_overridable_library "bpy.types.bpy_struct.is_property_overridable_library") - [`bpy_struct.is_property_readonly`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.is_property_readonly "bpy.types.bpy_struct.is_property_readonly") - [`bpy_struct.is_property_set`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.is_property_set "bpy.types.bpy_struct.is_property_set") - [`bpy_struct.items`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.items "bpy.types.bpy_struct.items") - [`bpy_struct.keyframe_delete`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.keyframe_delete "bpy.types.bpy_struct.keyframe_delete") - [`bpy_struct.keyframe_insert`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.keyframe_insert "bpy.types.bpy_struct.keyframe_insert") - [`bpy_struct.keys`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.keys "bpy.types.bpy_struct.keys") - [`bpy_struct.path_from_id`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.path_from_id "bpy.types.bpy_struct.path_from_id") - [`bpy_struct.path_from_module`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.path_from_module "bpy.types.bpy_struct.path_from_module") - [`bpy_struct.path_resolve`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.path_resolve "bpy.types.bpy_struct.path_resolve") - [`bpy_struct.pop`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.pop "bpy.types.bpy_struct.pop") - [`bpy_struct.property_overridable_library_set`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.property_overridable_library_set "bpy.types.bpy_struct.property_overridable_library_set") - [`bpy_struct.property_unset`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.property_unset "bpy.types.bpy_struct.property_unset") - [`bpy_struct.rna_ancestors`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.rna_ancestors "bpy.types.bpy_struct.rna_ancestors") | - [`bpy_struct.type_recast`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.type_recast "bpy.types.bpy_struct.type_recast") - [`bpy_struct.values`](bpy.types.bpy_struct.html#bpy.types.bpy_struct.values "bpy.types.bpy_struct.values") - [`ID.bl_system_properties_get`](bpy.types.ID.html#bpy.types.ID.bl_system_properties_get "bpy.types.ID.bl_system_properties_get") - [`ID.rename`](bpy.types.ID.html#bpy.types.ID.rename "bpy.types.ID.rename") - [`ID.evaluated_get`](bpy.types.ID.html#bpy.types.ID.evaluated_get "bpy.types.ID.evaluated_get") - [`ID.copy`](bpy.types.ID.html#bpy.types.ID.copy "bpy.types.ID.copy") - [`ID.asset_mark`](bpy.types.ID.html#bpy.types.ID.asset_mark "bpy.types.ID.asset_mark") - [`ID.asset_clear`](bpy.types.ID.html#bpy.types.ID.asset_clear "bpy.types.ID.asset_clear") - [`ID.asset_generate_preview`](bpy.types.ID.html#bpy.types.ID.asset_generate_preview "bpy.types.ID.asset_generate_preview") - [`ID.override_create`](bpy.types.ID.html#bpy.types.ID.override_create "bpy.types.ID.override_create") - [`ID.override_hierarchy_create`](bpy.types.ID.html#bpy.types.ID.override_hierarchy_create "bpy.types.ID.override_hierarchy_create") - [`ID.user_clear`](bpy.types.ID.html#bpy.types.ID.user_clear "bpy.types.ID.user_clear") - [`ID.user_remap`](bpy.types.ID.html#bpy.types.ID.user_remap "bpy.types.ID.user_remap") - [`ID.make_local`](bpy.types.ID.html#bpy.types.ID.make_local "bpy.types.ID.make_local") - [`ID.user_of_id`](bpy.types.ID.html#bpy.types.ID.user_of_id "bpy.types.ID.user_of_id") - [`ID.animation_data_create`](bpy.types.ID.html#bpy.types.ID.animation_data_create "bpy.types.ID.animation_data_create") - [`ID.animation_data_clear`](bpy.types.ID.html#bpy.types.ID.animation_data_clear "bpy.types.ID.animation_data_clear") - [`ID.update_tag`](bpy.types.ID.html#bpy.types.ID.update_tag "bpy.types.ID.update_tag") - [`ID.preview_ensure`](bpy.types.ID.html#bpy.types.ID.preview_ensure "bpy.types.ID.preview_ensure") - [`ID.bl_rna_get_subclass`](bpy.types.ID.html#bpy.types.ID.bl_rna_get_subclass "bpy.types.ID.bl_rna_get_subclass") - [`ID.bl_rna_get_subclass_py`](bpy.types.ID.html#bpy.types.ID.bl_rna_get_subclass_py "bpy.types.ID.bl_rna_get_subclass_py") |

### References

|  |  |
| --- | --- |
| - [`BlendData.node_groups`](bpy.types.BlendData.html#bpy.types.BlendData.node_groups "bpy.types.BlendData.node_groups") - [`BlendDataNodeTrees.new`](bpy.types.BlendDataNodeTrees.html#bpy.types.BlendDataNodeTrees.new "bpy.types.BlendDataNodeTrees.new") - [`BlendDataNodeTrees.remove`](bpy.types.BlendDataNodeTrees.html#bpy.types.BlendDataNodeTrees.remove "bpy.types.BlendDataNodeTrees.remove") - [`CompositorNodeCustomGroup.node_tree`](bpy.types.CompositorNodeCustomGroup.html#bpy.types.CompositorNodeCustomGroup.node_tree "bpy.types.CompositorNodeCustomGroup.node_tree") - [`CompositorNodeGroup.node_tree`](bpy.types.CompositorNodeGroup.html#bpy.types.CompositorNodeGroup.node_tree "bpy.types.CompositorNodeGroup.node_tree") - [`EvaluateClosureNodeViewerPathElem.source_node_tree`](bpy.types.EvaluateClosureNodeViewerPathElem.html#bpy.types.EvaluateClosureNodeViewerPathElem.source_node_tree "bpy.types.EvaluateClosureNodeViewerPathElem.source_node_tree") - [`FreestyleLineStyle.node_tree`](bpy.types.FreestyleLineStyle.html#bpy.types.FreestyleLineStyle.node_tree "bpy.types.FreestyleLineStyle.node_tree") - [`GeometryNodeCustomGroup.node_tree`](bpy.types.GeometryNodeCustomGroup.html#bpy.types.GeometryNodeCustomGroup.node_tree "bpy.types.GeometryNodeCustomGroup.node_tree") - [`GeometryNodeGroup.node_tree`](bpy.types.GeometryNodeGroup.html#bpy.types.GeometryNodeGroup.node_tree "bpy.types.GeometryNodeGroup.node_tree") - [`Light.node_tree`](bpy.types.Light.html#bpy.types.Light.node_tree "bpy.types.Light.node_tree") - [`Material.node_tree`](bpy.types.Material.html#bpy.types.Material.node_tree "bpy.types.Material.node_tree") - [`Node.poll`](bpy.types.Node.html#bpy.types.Node.poll "bpy.types.Node.poll") - [`Node.poll_instance`](bpy.types.Node.html#bpy.types.Node.poll_instance "bpy.types.Node.poll_instance") - [`NodeCustomGroup.node_tree`](bpy.types.NodeCustomGroup.html#bpy.types.NodeCustomGroup.node_tree "bpy.types.NodeCustomGroup.node_tree") - [`NodeGroup.node_tree`](bpy.types.NodeGroup.html#bpy.types.NodeGroup.node_tree "bpy.types.NodeGroup.node_tree") - [`NodeInternal.poll`](bpy.types.NodeInternal.html#bpy.types.NodeInternal.poll "bpy.types.NodeInternal.poll") - [`NodeInternal.poll_instance`](bpy.types.NodeInternal.html#bpy.types.NodeInternal.poll_instance "bpy.types.NodeInternal.poll_instance") - [`NodeTree.contains_tree`](#bpy.types.NodeTree.contains_tree "bpy.types.NodeTree.contains_tree") | - [`NodeTree.get_from_context`](#bpy.types.NodeTree.get_from_context "bpy.types.NodeTree.get_from_context") - [`NodeTreePath.node_tree`](bpy.types.NodeTreePath.html#bpy.types.NodeTreePath.node_tree "bpy.types.NodeTreePath.node_tree") - [`NodesModifier.node_group`](bp