code: protected void removeVersionable() throws RepositoryException, ConstraintViolationException, VersionException
     {
        if (isNode())
        {
           NodeTypeDataManager ntManager = session.getWorkspace().getNodeTypesHolder();
           NodeData node = (NodeData)data;
           if (ntManager.isNodeType(Constants.MIX_VERSIONABLE, node.getPrimaryTypeName(), node.getMixinTypeNames()))
           {
  
              ItemData vhpd =
                 dataManager.getItemData(node, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1), ItemType.PROPERTY);
              if (vhpd != null && !vhpd.isNode())
              {
                 String vhID = ValueDataUtil.getString(((PropertyData)vhpd).getValues().get(0));
                 dataManager.removeVersionHistory(vhID, null, data.getQPath());
              }
              else
              {
                 throw new RepositoryException("Version history not found for " + node.getQPath().getAsString());
              }
           }
        }
     }
docs: Check when it's a Node and is versionable will a version history removed.
  Case of last version in version history.
  
  @throws RepositoryException
  @throws ConstraintViolationException
  @throws VersionException