protected function doInsertBefore() {
    $request = $this->getRequest();
    $persistenceFacade = $this->getPersistenceFacade();
    $isOrderBottom = $this->isOrderBotton($request);

    // load the moved object, the reference object and the conainer object
    $insertOid = ObjectId::parse($request->getValue('insertOid'));
    $referenceOid = ObjectId::parse($request->getValue('referenceOid'));
    $containerOid = ObjectId::parse($request->getValue('containerOid'));
    $insertObject = $persistenceFacade->load($insertOid);
    $referenceObject = $isOrderBottom ? new NullNode() : $persistenceFacade->load($referenceOid);
    $containerObject = $persistenceFacade->load($containerOid);

    // check object existence
    $objectMap = ['insertOid' => $insertObject,
        'referenceOid' => $referenceObject,
        'containerOid' => $containerObject];
    if ($this->checkObjects($objectMap)) {
      $role = $request->getValue('role');
      $originalChildren = $containerObject->getValue($role);
      // add the new node to the container, if it is not yet
      $nodeExists = sizeof(Node::filter($originalChildren, $insertOid)) == 1;
      if (!$nodeExists) {
        $containerObject->addNode($insertObject, $role);
      }
      // reorder the children list
      $orderedChildren = [];
      foreach ($originalChildren as $curChild) {
        $oid = $curChild->getOID();
        if ($oid == $referenceOid) {
          $orderedChildren[] = $insertObject;
        }
        if ($oid != $insertOid) {
          $orderedChildren[] = $curChild;
        }
      }

      // get the sortkey values of the objects before and after the insert position
      if ($isOrderBottom) {
        $orderedChildren[] = $insertObject;
      }
      $containerObject->setNodeOrder($orderedChildren, [$insertObject], $role);
    }
  }