Graph planarity by replacing cliques with paths