Implement Array#flatten(depth).