js: recursive pop for javascript objects