Planting trees around rivers could reduce the height of flooding in towns by up to 20%, new research says.