Recent technologies of district heating and cooling (DHC) systems integrate renewable energy sources and connect multiple heat producers and consumers to the same network. The resulting interactions may therefore cause the fluid in the pipe, or the energy carried by the system, to flow in both directions. This article presents a newly developed analytical method for evaluating the hydraulic states in DHC networks with bidirectional mass and energy flows. The formulation of the method is presented in detail and is mainly based on the definition of two functions, namely, the flow-pressure function and the bifurcation function. The former describes the relationship between the pressure drop and the mass flow rate in a circular pipe segment, whereas the latter finds the sum of all pressure differences in a closed loop and has a single unique zero that determines the unknown mass flow rate to fulfill network mass balance. Several examples are provided to demonstrate the applicability of the method to single- and multi-looped network topologies. The method enables robust and fast calculations for virtually any network configuration with any number of connected prosumers. It can be easily implemented in any design and simulation tool to account for steady-state or dynamic situations.