Similarities between structural distortions under pressure and chemical doping in superconducting BaFe2As2