code: public QPath makeAncestorPath(int relativeDegree)
     {
        int entryCount = getLength() - relativeDegree;
        QPathEntry[] ancestorEntries = new QPathEntry[entryCount];
        for (int i = 0; i < entryCount; i++)
        {
           QPathEntry entry = names[i];
           ancestorEntries[i] = new QPathEntry(entry.getNamespace(), entry.getName(), entry.getIndex());
        }
  
        return new QPath(ancestorEntries);
     }
docs: Makes ancestor path by relative degree (For ex relativeDegree == 1 means parent path etc)
  
  @param relativeDegree
  @return