expanded sum() to include deep iteration functionality