A new method for calculating a special class of self-consistent three-dimensional magnetohydrostatic equilibria