module CmAdmin::Utils

def base(hash, key, tokens) # recursive

recursive
def base(hash, key, tokens) # recursive
  hash.empty? && hash = { columns: [], associations: recursive_hash }
  if tokens.empty?
    # base case
    hash[:columns] << key
  else
    # recursive case
    # hash[:associations] ||= {}
    hash[:associations][key] = base(hash[:associations][key], tokens.shift, tokens)
  end
  hash
end