A celebrated result of Morse and Hedlund, stated in 1938, asserts that a sequence $x$ over a finite alphabet is ultimately periodic if and only if, for some $n$, the number of different factors of length $n$ appearing in $x$ is less than $n+1$. Attempts to extend this fundamental result, for example, to higher dimensions, have been considered during the last fifteen years. Let $dge 2$. A legitimate extension to a multidimensional setting of the notion of periodicity is to consider sets of $ZZ^d$ definable by a first order formula in the Presburger arithmetic $<ZZ;<,+>$. With this latter notion and using a powerful criterion due to Muchnik, we exhibit a complete extension of the Morse--Hedlund theorem to an arbitrary dimension $d$ and characterize sets of $ZZ^d$ definable in $<ZZ;<,+>$ in terms of some functions counting recurrent blocks, that is, blocks occurring infinitely often.