The Galaxy and the stars in it form a hierarchical system, such that the properties of individual stars are influenced by those of the Galaxy. Here, an approach is described which uses hierarchical Bayesian models to simultaneously and empirically determine the mean distance-extinction relationship for a sightline and the properties of stars which populate it. By exploiting the hierarchical nature of the problem, the method described is able to achieve significantly improved precision and accuracy with respect to previous 3D extinction mapping techniques. This method is not tied to any individual survey and could be applied to any observations, or combination of observations available. Furthermore, it is extendible and, in addition, could be employed to study Galactic structure as well as factors such as the initial mass function and star formation history in the Galaxy.