class ActiveRecord::Associations::JoinDependency

def self.walk_tree(associations, hash)

def self.walk_tree(associations, hash)
  case associations
  when Symbol, String
    hash[associations.to_sym] ||= {}
  when Array
    associations.each do |assoc|
      walk_tree assoc, hash
    end
  when Hash
    associations.each do |k, v|
      cache = hash[k] ||= {}
      walk_tree v, cache if v
    end
  else
    raise ConfigurationError, associations.inspect
  end
end