code: private void checkPersistedSNS(NodeData node, WorkspaceStorageConnection acon) throws RepositoryException
     {
        NodeData parent = (NodeData)acon.getItemData(node.getParentIdentifier());
        QPathEntry myName = node.getQPath().getEntries()[node.getQPath().getEntries().length - 1];
        ItemData sibling =
           acon.getItemData(parent, new QPathEntry(myName.getNamespace(), myName.getName(), myName.getIndex() - 1),
              ItemType.NODE);
  
        if (sibling == null || !sibling.isNode())
        {
           throw new InvalidItemStateException("Node can't be saved " + node.getQPath().getAsString()
              + ". No same-name sibling exists with index " + (myName.getIndex() - 1) + ".");
        }
     }
docs: Check if same-name sibling exists in persistence.