Implement "toList" function.