def final_merge

      wi = if h.workitem

        h.workitem

      elsif h.cmerge_type == 'ignore' || h.workitems.nil? || h.workitems.empty?

        h.applied_workitem

      else

        wis = h.workitems

        if %w[ highest lowest ].include?(h.cmerge)
          wis = h.workitems.sort_by { |wi| wi['fei']['expid'] }
        end

        if
          %w[ first highest ].include?(h.cmerge) &&
          ! %w[ stack union concat deep ].include?(h.cmerge_type)
        then
          wis = wis.reverse
        end

        as, bs = wis.partition { |wi| wi.delete('winner') }
        wis = bs + as
          #
          # the 'winner' is the workitem that triggered successfully the
          # :over_if or :over_unless, let's take him precedence in the merge...

        merge_workitems(wis, h.cmerge_type)
      end

      if h.cmerge_type == 'stack'
        wi['fields']['stack_attributes'] = compile_atts
      end

      wi
    end
def final_merge

      wi = if h.workitem

        h.workitem

      elsif h.cmerge_type == 'ignore' || h.workitems.nil? || h.workitems.empty?

        h.applied_workitem

      else

        wis = h.workitems

        if %w[ highest lowest ].include?(h.cmerge)
          wis = h.workitems.sort_by { |wi| wi['fei']['expid'] }
        end

        if
          %w[ first highest ].include?(h.cmerge) &&
          ! %w[ stack union concat deep ].include?(h.cmerge_type)
        then
          wis = wis.reverse
        end

        as, bs = wis.partition { |wi| wi.delete('winner') }
        wis = bs + as
          #
          # the 'winner' is the workitem that triggered successfully the
          # :over_if or :over_unless, let's take him precedence in the merge...

        merge_workitems(wis, h.cmerge_type)
      end

      if h.cmerge_type == 'stack'
        wi['fields']['stack_attributes'] = compile_atts
      end

      wi
    end
Called by #reply_to_parent, returns the unique, merged, workitem that
 will be fed back to the parent expression.