/// <summary>
 /// Returns true if this is a descendant of parent.
 /// </summary>
 /// <returns>True if this is a descendant of parent.</returns>
 /// <param name="parent">parent</param>
 public bool IsDescendantOf(HierarchyId parent)
 {
     if (parent.GetLevel() > GetLevel())
     {
         return false;
     }
     for (int i = 0; i < parent.GetLevel(); i++)
     {
         int cmp = CompareIntArrays(GetNodes()[i], parent.GetNodes()[i]);
         if (cmp != 0)
         {
             return false;
         }
     }
     return true;
 }
 public HierarchyId GetReparentedValue(HierarchyId oldRoot, HierarchyId newRoot)
 {
     if (!IsDescendantOf(oldRoot))
     {
         throw new ArgumentException(
             string.Format(CultureInfo.InvariantCulture, GetReparentedValueOldRootExceptionMessage, oldRoot, ToString()), "oldRoot");
     }
     StringBuilder sb = new StringBuilder();
     sb.Append(PathSeparator);
     foreach (var node in newRoot.GetNodes())
     {
         sb.Append(IntArrayToString(node));
         sb.Append(PathSeparator);
     }
     foreach (var node in GetNodes().Skip(oldRoot.GetLevel()))
     {
         sb.Append(IntArrayToString(node));
         sb.Append(PathSeparator);
     }
     return new HierarchyId(sb.ToString());
 }