/**
  * Helper method which retrieves the next version in the history tree. This method must be used in
  * reversed order. With the introduction of branches, the versions are organized in a tree
  * structure. Therefore, next versions are always searched for walking up the tree.
  *
  * @param currentVersion current version
  * @return version
  * @throws InvalidVersionSpecException if the path can't be followed further
  */
 public static Version findNextVersion(Version currentVersion) throws InvalidVersionSpecException {
   // find next version
   if (currentVersion.getPreviousVersion() != null) {
     currentVersion = currentVersion.getPreviousVersion();
   } else if (currentVersion.getAncestorVersion() != null) {
     currentVersion = currentVersion.getAncestorVersion();
   } else {
     throw new InvalidVersionSpecException(Messages.VersionSubInterfaceImpl_NextVersionInvalid);
   }
   return currentVersion;
 }
 private PrimaryVersionSpec resolveDateVersionSpec(
     ProjectHistory projectHistory, DateVersionSpec versionSpec) {
   for (final Version version : projectHistory.getVersions()) {
     final LogMessage logMessage = version.getLogMessage();
     if (logMessage == null || logMessage.getDate() == null) {
       continue;
     }
     if (versionSpec.getDate().before(logMessage.getDate())) {
       final Version previousVersion = version.getPreviousVersion();
       if (previousVersion == null) {
         return VersioningFactory.eINSTANCE.createPrimaryVersionSpec();
       }
       return previousVersion.getPrimarySpec();
     }
   }
   return projectHistory.getLastVersion().getPrimarySpec();
 }