protected function getSortkeyValue(Node $node) {
    // if no role is defined for a or b, the sortkey is
    // determined from the type of the reference node
    $defaultRole = $this->referenceNode->getType();
    $referenceMapper = $this->referenceNode->getMapper();
    $mapper = $node->getMapper();

    if ($referenceMapper && $mapper) {

      $referenceRole = $defaultRole;
      // get the sortkey of the node for the relation to the reference node,
      // if a role is defined
      $oidStr = $node->getOID()->__toString();
      if (isset($this->oidRoleMap[$oidStr])) {
        $nodeRole = $this->oidRoleMap[$oidStr];
        $relationDesc = $referenceMapper->getRelation($nodeRole);
        $referenceRole = $relationDesc->getThisRole();
      }
      $sortkeyDef = $mapper->getSortkey($referenceRole);
      return $node->getValue($sortkeyDef['sortFieldName']);
    }
    return 0;
  }