def process_pair(pair)
      case pair
      when Hash
        if pair.length != 1
          raise ArgumentError.new("Bad # of fields for pair: #{pair.inspect}")
        end
        pair.to_a.fetch(0)
      when Array
        if pair.length > 2
          raise ArgumentError.new("Bad # of fields for pair: #{pair.inspect}")
        end
        [pair.fetch(0), pair[1]]
      else
        # recurse, converting any non-array to an array
        process_pair(pair.to_a)
      end
    end
def process_pair(pair)
      case pair
      when Hash
        if pair.length != 1
          raise ArgumentError.new("Bad # of fields for pair: #{pair.inspect}")
        end
        pair.to_a.fetch(0)
      when Array
        if pair.length > 2
          raise ArgumentError.new("Bad # of fields for pair: #{pair.inspect}")
        end
        [pair.fetch(0), pair[1]]
      else
        # recurse, converting any non-array to an array
        process_pair(pair.to_a)
      end
    end
A pair may be:
 - A single element hash, e.g. {foo: 'bar'}
 - A two element array, e.g. ['foo', 'bar']
 - A one element array, e.g. ['foo']