A recursive basis for primitive forms in symplectic spaces and applications to Heisenberg groups