There is a way to get the maximum berries possible from each tree. Sometimes, the tree won't start to shake after you shake it once. Then you can keep going for a while. Normally, it will shake quite steadily after you shake it for the first time. Other times, it will shake quickly after you shake it. Once you get the tree shaking in the fast speed, you can normally shake it once more before a Pokemon will attack.