code: public NodeData getAggregateRoot(NodeData nodeState) throws RepositoryException
     {
        for (int i = 0; i < nodeIncludes.length; i++)
        {
           NodeData aggregateRoot = nodeIncludes[i].matches(nodeState);
           if (aggregateRoot != null && aggregateRoot.getPrimaryTypeName().equals(nodeTypeName))
           {
              return aggregateRoot;
           }
        }
        // check property includes
        for (int i = 0; i < propertyIncludes.length; i++)
        {
           NodeData aggregateRoot = propertyIncludes[i].matches(nodeState);
           if (aggregateRoot != null && aggregateRoot.getPrimaryTypeName().equals(nodeTypeName))
           {
              return aggregateRoot;
           }
        }
        return null;
     }
docs: Returns root node state for the indexing aggregate where
  <code>nodeState</code> belongs to.
  
  @param nodeState the node state.
  @return the root node state of the indexing aggregate or
  <code>null</code> if <code>nodeState</code> does not belong to an
  indexing aggregate.
  @throws ItemStateException  if an error occurs.
  @throws RepositoryException if an error occurs.