code: private void migrateGroups() throws Exception
     {
        Session session = service.getStorageSession();
        try
        {
           if (session.itemExists(groupsStorageOld))
           {
              NodeIterator iterator = ((ExtendedNode)session.getItem(groupsStorageOld)).getNodesLazily();
              GroupHandlerImpl gh = ((GroupHandlerImpl)service.getGroupHandler());
              while (iterator.hasNext())
              {
                 Node oldGroupNode = iterator.nextNode();
                 gh.migrateGroup(oldGroupNode);
                 migrateGroups(oldGroupNode);
              }
           }
        }
        finally
        {
           session.logout();
        }
     }
docs: Method for groups migration. Must be run after users and membershipTypes migration.
  @throws Exception