Rydberg atoms in Bose-Einstein condensates and optical lattices