# File lib/polyamorous/activerecord_4.2_ruby_1.9/join_dependency.rb, line 67
      def walk_tree_with_polymorphism(associations, hash)
        case associations
        when TreeNode
          associations.add_to_tree(hash)
        when Hash
          associations.each do |k, v|
            cache =
              if TreeNode === k
                k.add_to_tree(hash)
              else
                hash[k] ||= {}
              end
            walk_tree(v, cache)
         end
        else
          walk_tree_without_polymorphism(associations, hash)
        end
      end