There are a few operators and menus (Merge Selected Node, Switch Node Type, etc.) which don't work well with custom node tree add-ons like Animation nodes or Sverchok - reported here. This patch avoids that the panel and the operators are accessible within custom node trees.
Another approach would be adding a check to all menu items as well as adding poll methods to the operators in order to provide at least all basic functionality like Swap Links, Add Reroutes, Link Active to Selected and so on, but I'm not sure whether it's worth it :)
Mockup
Implementation proposal
#
# P A N E L
#
def drawlayout(context, layout, mode='non-panel'):
tree_type = context.space_data.tree_type
valid_trees = ["ShaderNodeTree", "CompositorNodeTree", "TextureNodeTree"]
supported = bool([i for i in valid_trees if tree_type in valid_trees])
if supported:
col = layout.column(align=True)
col.menu(NWMergeNodesMenu.bl_idname)
col.separator()
col = layout.column(align=True)
col.menu(NWSwitchNodeTypeMenu.bl_idname, text="Switch Node Type")
col.separator()
if tree_type == 'ShaderNodeTree' and context.scene.render.engine == 'CYCLES':
col = layout.column(align=True)
col.operator(NWAddTextureSetup.bl_idname, text="Add Texture Setup", icon='NODE_SEL')
col.separator()