In matching models, pairwise stable outcomes do not generally exist without substantial restrictions on both preferences and the topology of the network of contracts. We address the foundations of matching markets by developing a matching model with a continuum of agents that allows for arbitrary preferences and network structures. We show that pairwise stable outcomes are guaranteed to exist. When agents can interact with multiple other counterparties, pairwise stability is too weak of a solution concept, and we argue that a refinement of it called tree stability is the most appropriate solution concept in this setting. Our main results show tree-stable outcomes exist for arbitrary preferences and network topologies.