TREESPH - A unification of SPH with the hierarchical tree method. A new, general-purpose code for evolving three-dimensional, self-gravitating fluids in astrophyics, both with and without collisionless matter, is described. In this TREESPH code, hydrodynamic properties are determined using a Monte Carlo-like approach known as smoothed particle hydrodynamics (SPH). Unlike most previous implementations of SPH, gravitational forces are computed with a hierarchical tree algorithm. Multiple expansions are used to approximate the potential of distant groups of particles, reducing the cost per step. More significantly, the improvement in efficiency is achieved without the introduction of a grid. A unification of SPH with the hierarchical tree method is a natural way of allowing for larger N within a Lagrangian framework. The data structures used to manipulate the grouping of particles can be applied directly to certain aspects of the SPH calculation