If you have a mixture of metal cations in solution, add chloride ions (in the form of HCl) to precipitate Ag+, Pb2+, and Hg22+ as their insoluble chlorides. The precipitate is removed by filtration and the rest of the cations stay in solution.
Note: the lack of a precipitate in any of these precipitation steps confirms the absence of all cations in that set.
In contrast, formation of a precipitate indicates the presence of at least one of the ions in that set, possibly more.
To the filtered, acidic solution from above, add sulfide ions (in the form of H2S). If present, Bi3+, Cd2+, Cu2+, Hg2+, Pb2+, Sb3+, Sn2+, and Sn4+ precipitate as their insoluble sulfides, and are removed by filtration. The rest of the cations stay in solution.
Increase the pH of the filtered solution from above and add more H2S. If present, Al3+, Co2+, Cr3+, Fe2+, Fe3+, Ni2+, Mn2+, and Zn2+ precipitate as hydroxides, or sulfides (or both), and are removed by filtration. The rest of the cations stay in solution.
To the filtered solution from above, add carbonate ions (or phosphate ions). If present, Ba2+, Ca2+, Mg2+, and Sr2+ precipitate as their carbonates (or phosphates) to be removed by filtration. The rest of the cations stay in solution and cannot be precipitated.