This paper describes an algorithm that, by combining heuristic methods and a genetic algorithm, enables optimal reconfiguration of medium-voltage distribution networks while satisfying all operating constraints and maintaining the radial structure. The proposed algorithm introduces a number of improvements compared to previous similar achievements, which enables it to be applied to real distribution networks. With the algorithm, it is possible to achieve two goal functions, minimization of total losses of active power or equalization of load in the network. The algorithm was tested on standard test networks where it was shown that the complexity of the network does not affect the efficiency of the algorithm. In addition to standard test networks, the algorithm was also tested on a real medium-voltage distribution network, and the calculation results show the quality and accuracy of the obtained results. The algorithm leaves enough room for the introduction of further modifications in order to achieve better efficiency.