Potential energy function of polyatomic molecules: Automatic determination of the unitary transformation operator for the perturbation treatment of the Hamiltonian