Blender UI panel custom property doesn't show up
Setter / Getter on property



Something like this can be done with an update, or setter and getter on a blender property.  The operator has been ditched altogether.

Because the compositor is being used, the Scene type is a natural choice. For shader nodes choose  Material.

The getter returns how many math nodes are in the node tree.

The setter adds more if greater.

Haven't wired in removing the nodes. Would consider removing nodes to match input number as long as they have no links. 

import bpy
from bpy.props import IntProperty

class NODES_PT_math_nodes(bpy.types.Panel):
    bl_label = "Too many Nodes"
    bl_idname = "NODES_PT_math_nodes"
    bl_space_type = 'NODE_EDITOR'
    bl_region_type = 'UI'

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        col = layout.column()
        col.prop(scene, 'math_nodes')


def get_math_nodes(self):
    node_tree = self.node_tree
    return len([n for n in node_tree.nodes if n.type == "MATH"])

def set_math_nodes(self, value):
    node_tree = self.node_tree
    nodes = node_tree.nodes
    m = get_math_nodes(self)
    delta = value - m
    if delta &gt; 0:
        for i in range(delta):
            n = nodes.new(type="CompositorNodeMath")
            n.location.x += (m) * (n.width + 20)

def register():    
    bpy.utils.register_class(NODES_PT_math_nodes)
    bpy.types.Scene.math_nodes = IntProperty(
            min=0,
            soft_max=10,
            get=get_math_nodes,
            set=set_math_nodes)

register()