Prediction of protein folding rates and folding nuclei is an important problem of protein science. Most of the previously proposed models for protein folding in vitro are based on the nucleation mechanism of this process. Our model considering protein folding as a flow arising in a network of folding-unfolding pathways at a coarse-grained free-energy landscape was described a few years ago, along with an algorithm for calculation of protein folding rates. Here we extend our approach and describe in detail a mathematically strict algorithm for calculating the "folding nuclei", arising as bottlenecks of the flow. Although the proposed physical theory uses no adjustable parameters, its results are in good agreement with experiment. This paper presents (i) the general theory and (ii) the results for the simplest case, i.e., folding/unfolding at the midpoint of thermodynamic equilibrium between the native and unfolded states of a protein; results for "in-water" conditions, i.e., for the case when no denaturant is added and the native state of a protein is much more stable than the unfolded one, will be described in the next paper of the series.