An ellipsometric method for reconstructing the thickness compositional profile in thin heterostructure nanolayers grown by molecular beam epitaxy on the basis of a cadmium–mercury–tellurium compound has been developed. The method is based on solving an inverse ellipsometric problem with the replacement of part of an inhomogeneous layer with a homogeneous medium with specially selected optical constants. The numerical simulation has confirmed the correctness of this replacement and efficiency of the developed algorithm. Using this method, the active region of a heterostructure consisting of five HgTe quantum wells separated by wide-gap CdHgTe spacers has been investigated. Based on the results of continuous in situ ellipsometry measurements performed during the heterostructure growth, the compositional profiles for all the five sequentially grown quantum wells have been calculated and the high reproducibility of the thickness dependences of their composition has been demonstrated.