private static Level GetLevelElement(AbstractNum abstractNum, int levelIndex) { var oxmlLevel = abstractNum.Elements <Level>().FirstOrDefault(lv => { return(lv.LevelIndex.Value == levelIndex); }); if (oxmlLevel == null) { throw new OpenXmlPackageException(string.Format("Couldn't find the Level element by the level index (LevelIndex:{0})", levelIndex)); } return(oxmlLevel); }