code:     public static boolean isNewAuthenticationPathNeeded(long globalIndex, int xmssHeight, int layer)
      {
          if (globalIndex == 0)
          {
              return false;
          }
          return ((globalIndex + 1) % (long)Math.pow((1 << xmssHeight), layer) == 0) ? true : false;
      }
  