static mitk::DataNode::Pointer GetTopLayerNode(const mitk::DataStorage::SetOfObjects::ConstPointer nodes, const mitk::Point3D &position, mitk::BaseRenderer* renderer)
{
  mitk::DataNode::Pointer node;
  int  maxlayer = -32768;

  if(nodes.IsNotNull())
  {
    // find node with largest layer, that is the node shown on top in the render window
    for (unsigned int x = 0; x < nodes->size(); x++)
    {
      if ( (nodes->at(x)->GetData()->GetGeometry() != nullptr) &&
           nodes->at(x)->GetData()->GetGeometry()->IsInside(position) )
      {
        int layer = 0;
        if(!(nodes->at(x)->GetIntProperty("layer", layer))) continue;
        if(layer > maxlayer)
        {
          if( static_cast<mitk::DataNode::Pointer>(nodes->at(x))->IsVisible(renderer) )
          {
            node = nodes->at(x);
            maxlayer = layer;
          }
        }
      }
    }
  }

  return node;
}
mitk::DataNode::Pointer SliceNavigationController::GetTopLayerNode(mitk::DataStorage::SetOfObjects::ConstPointer nodes,mitk::Point3D worldposition)
{
  mitk::DataNode::Pointer node;
  int  maxlayer = -32768;
  bool isHelper (false);
  if(nodes.IsNotNull())
  {
    for (unsigned int x = 0; x < nodes->size(); x++)
    {
      nodes->at(x)->GetBoolProperty("helper object", isHelper);
      if(nodes->at(x)->GetData()->GetGeometry()->IsInside(worldposition) && isHelper == false)
      {
        int layer = 0;
        if(!(nodes->at(x)->GetIntProperty("layer", layer))) continue;
        if(layer > maxlayer)
        {
          if(static_cast<mitk::DataNode::Pointer>(nodes->at(x))->IsVisible(m_Renderer))
          {
            node = nodes->at(x);
            maxlayer = layer;
          }
        }
      }
    }
  }
  return node;
}