Coexistence of, and competition between, superconductivity and magnetism in YbPd2Sn