public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert, boolean includeSelf) {
if (node.getNodeType() == Node.ATTRIBUTE_NODE)
{return null;}
final IndexSpec indexConf = node.getDocument().getCollection().getIndexConfiguration(broker);
if (indexConf != null) {
final FulltextIndexSpec config = indexConf.getFulltextIndexSpec();
if (config == null)
{return null;}
boolean reindexRequired = false;
final int len = node.getNodeType() == Node.ELEMENT_NODE && !includeSelf ? path.length() - 1 : path.length();
for (int i = 0; i < len; i++) {
final QName qn = path.getComponent(i);
if (config.hasQNameIndex(qn)) {
reindexRequired = true;
break;
}
}
if (reindexRequired) {
StoredNode topMost = null;
StoredNode currentNode = node;
while (currentNode != null) {
if (config.hasQNameIndex(currentNode.getQName()))
{topMost = currentNode;}
currentNode = currentNode.getParentStoredNode();
}
return topMost;
}