private void deleteOldIntermediatePath(final Session session,Node oldIntermediateNode) throws RepositoryException, PathNotFoundException, VersionException, LockException, ConstraintViolationException, AccessDeniedException {
  while (!StringUtils.equals(PATH_HOME_GROUPS,oldIntermediateNode.getPath()) && !StringUtils.equals(PATH_HOME_USERS,oldIntermediateNode.getPath()) && !oldIntermediateNode.hasNodes()) {
    Node parent=oldIntermediateNode.getParent();
    session.removeItem(oldIntermediateNode.getPath());
    oldIntermediateNode=parent;
  }
}

private void deleteOldIntermediatePath ( final Session session , Node oldIntermediateNode ) throws RepositoryException , PathNotFoundException , VersionException , LockException , ConstraintViolationException , AccessDeniedException { while ( ! StringUtils . equals ( PATH_HOME_GROUPS , oldIntermediateNode . getPath ( ) ) && ! StringUtils . equals ( PATH_HOME_USERS , oldIntermediateNode . getPath ( ) ) && ! oldIntermediateNode . hasNodes ( ) ) { Node parent = oldIntermediateNode . getParent ( ) ; session . removeItem ( oldIntermediateNode . getPath ( ) ) ; oldIntermediateNode = parent ; } }
/ / deletes old intermediatepath parent node and all empty parent nodes up to / home / groups or / home / users
