Local factorization of the fermion determinant in lattice QCD