def split_key(key, max = Float::INFINITY)
      parts = []
      pos   = 0
      return [key] if max == 1
      key_parts(key) do |part|
        parts << part
        pos += part.length + 1
        if parts.length + 1 >= max
          parts << key[pos..-1] unless pos == key.length
          break
        end
      end
      parts
    end
def split_key(key, max = Float::INFINITY)
      parts = []
      pos   = 0
      return [key] if max == 1
      key_parts(key) do |part|
        parts << part
        pos += part.length + 1
        if parts.length + 1 >= max
          parts << key[pos..-1] unless pos == key.length
          break
        end
      end
      parts
    end
split a key by dots (.)
 dots inside braces or parenthesis are not split on

 split_key 'a.b'      # => ['a', 'b']
 split_key 'a.#{b.c}' # => ['a', '#{b.c}']
 split_key 'a.b.c', 2 # => ['a', 'b.c']