code: private void createIndex(final Queue<Callable<Void>> tasks, final NodeData node, final ItemDataConsumer stateMgr,
        final AtomicLong count, final NodeData nodeData, final AtomicLong processed) throws RepositoryException,
        IOException, InterruptedException
     {
        NodeData childState = null;
        try
        {
           childState = (NodeData)stateMgr.getItemData(nodeData.getIdentifier());
        }
        catch (RepositoryException e)
        {
           LOG.error(
              "Error indexing subtree " + node.getQPath().getAsString() + ". Check JCR consistency. " + e.getMessage(), e);
           return;
        }
  
        if (childState == null)
        {
           LOG.error("Error indexing subtree " + node.getQPath().getAsString() + ". Item not found.");
           return;
        }
  
        if (nodeData != null)
        {
           createIndex(tasks, nodeData, stateMgr, count, processed);
        }
     }
docs: Recursively creates an index starting with the NodeState
  <code>node</code>.
  
  @param tasks
  the queue of existing indexing tasks
  @param node
  the current NodeState.
  @param stateMgr
  the shared item state manager.
  @param count
  the number of nodes already indexed.
  @param nodeData
  the node data to index.
  @throws IOException
  if an error occurs while writing to the index.
  @throws RepositoryException
  if any other error occurs
  @throws InterruptedException
  if the task has been interrupted