Reduce code duplication in getOptimizedActionList.