public static <A extends Action> float actionDuration(A action) {
		if (action instanceof FiniteDurationAction) {
			return ((FiniteDurationAction) action).getDuration();
		}
		if (action instanceof TemporalAction) {
			return ((TemporalAction) action).getDuration();
		}
		if (action instanceof DelayAction) {
			return ((DelayAction) action).getDuration() + actionDuration(((DelayAction) action).getAction());
		}
		if (action instanceof DelegateAction) {
			return actionDuration(((DelegateAction) action).getAction());
		}
		if (action instanceof SequenceAction) {
			float duration = 0;
			for (Action subAction : ((SequenceAction) action).getActions()) {
				duration += actionDuration(subAction);
			}
			return duration;
		}
		if (action instanceof ParallelAction) {
			float duration = 0;
			for (Action subAction : ((ParallelAction) action).getActions()) {
				duration = Math.max(duration, actionDuration(subAction));
			}
			return duration;
		}
		return 0;
	}