How to delete display node and allocated resources properly?

The process of adding support of multiple color bars via displayable manager PR #5828.

The color bar display node is added to the scalar volume:

  // Create color bar and observe color bar by displayable node
  vtkMRMLColorBarDisplayNode* colorBarNode = vtkMRMLColorBarDisplayNode::SafeDownCast(mrmlScene->AddNewNodeByClass("vtkMRMLColorBarDisplayNode"));
  if (colorBarNode)
    {
    volumeNode->AddAndObserveDisplayNodeID(colorBarNode->GetID());
    return colorBarNode;
    }

The information about different display nodes is stored in display manager in the std::map (key - color bar display node ID, values - VTK widget, actor, and so on).

typedef std::tuple< vtkSmartPointer<vtkSlicerScalarBarActor>, \
                    vtkSmartPointer<vtkScalarBarWidget>, \
                    bool > ColorBarTuple;
  /// Map stores color bar display node ID, tuple
  std::map< std::string, ColorBarTuple > ColorBarTupleMap;

If i delete color bar display node i also want to delete VTK objects from the map object in the displayable manager.

      /// Delete color bar display node
      int n = d->colorLogic()->GetColorBarDisplayNodeNumberByNode( d->volumeNode, d->ColorBarNode);
      if (n != -1)
        {
        d->volumeNode->RemoveNthDisplayNodeID(n);
        this->mrmlScene()->RemoveNode(d->ColorBarNode);
        }

But when i try to delete data from map in display manager the application crashes

//---------------------------------------------------------------------------
void vtkMRMLColorBarDisplayableManager::OnMRMLSceneNodeRemoved(vtkMRMLNode* node)
{
  this->Superclass::OnMRMLSceneNodeRemoved(node);

  if (!node || !this->GetMRMLScene())
    {
    vtkErrorMacro("OnMRMLSceneNodeRemoved: Invalid MRML scene or input node");
    return;
    }

  if (node->IsA("vtkMRMLColorBarDisplayNode"))
    {
    vtkUnObserveMRMLNodeMacro(node);

    vtkMRMLColorBarDisplayNode* dispNode = vtkMRMLColorBarDisplayNode::SafeDownCast(node);
 
    auto it = this->Internal->ColorBarTupleMap.find(node->GetID());
    if (it != this->Internal->ColorBarTupleMap.end())
      {
      /// Delete VTK objects

      this->Internal->ColorBarTupleMap.erase(it); /// Crash of the 3D Slicer
      }
    }
}

Could i delete nodes in a display manager, and what is the proper way to do that? For example in “Volume Rendering” module the display nodes are stored and deleted in a logic and not in display manager.