[FIXED JENKINS-24412][FIXED JENKINS-24410] Save only TopLevelItems

This reimplements #36 and #37 the way @jglick suggested.