javascript: removeIDs should remove nested identities