IEEE 802.15.4 multi-hop wireless networks are an important communication infrastructure for many applications, including industrial control, home automation, and smart grids. Existing analysis of the IEEE 802.15.4 medium access control (MAC) protocol are often based on assumptions of homogeneous traffic and ideal carrier sensing, which are far from the reality when predicting performance for multi-hop networks. In this paper, a generalized analysis of the unslotted IEEE 802.15.4 MAC is presented. The model considers heterogeneous traffic and hidden terminals due to limited carrier sensing capabilities, and allows us to investigate jointly IEEE 802.15.4 MAC and routing algorithms. The analysis is validated via Monte Carlo simulations, which show that routing over multi-hop networks is significantly influenced by the IEEE 802.15.4 MAC performance. Routing decisions based on packet loss probability may lead to an unbalanced distribution of the traffic load across paths, thus motivating th...