code: public void migrate(Node rootNode, String nodeType, List<String> mixinTypes, Map<String, String[]> permissions)
        throws RepositoryException
     {
        NodeIterator iter = ((NodeImpl)rootNode).getNodesLazily();
        while (iter.hasNext())
        {
           Node userNode = iter.nextNode();
  
           if (!alreadyMigrated(userNode))
           {
              Node ancestorNode = rootNode;
  
              Iterator<String> ancestors = getAncestors(userNode.getName()).iterator();
              while (ancestors.hasNext())
              {
                 String ancestorName = ancestors.next();
  
                 if (ancestors.hasNext())
                 {
                    try
                    {
                       ancestorNode = ancestorNode.getNode(ancestorName);
                       continue;
                    }
                    catch (PathNotFoundException e)
                    {
                       ancestorNode =
                          createNode(ancestorNode, ancestorName, nodeType, mixinTypes, permissions, false, false);
                    }
                 }
                 else
                 {
                    rootNode.getSession().move(userNode.getPath(), ancestorNode.getPath() + "/" + ancestorName);
                 }
              }
  
              rootNode.getSession().save();
           }
        }
     }
docs: {@inheritDoc}