Development of the Green function diagrammatic technique for local spins