def _compile_list(self, data, indent_level):
        """Correctly write possibly nested list."""
        if len(data) == 0:
            return '--'
        elif not any(isinstance(i, (dict, list)) for i in data):
            return ', '.join(self._compile_literal(value) for value in data)
        else:
            # 'ere be dragons,
            # granted there are fewer dragons than the parser,
            # but dragons nonetheless
            buffer = ''
            i = 0
            while i < len(data):
                if isinstance(data[i], dict):
                    buffer += '\n'
                    buffer += self._indent * indent_level
                    while i < len(data) and isinstance(data[i], dict):
                        buffer += '-\n'
                        buffer += self._compile_key_val(data[i], indent_level)
                        buffer += self._indent * indent_level + '-'
                        i += 1
                    buffer += '\n'
                elif (
                    isinstance(data[i], list) and
                    any(isinstance(item, (dict, list)) for item in data[i])
                ):
                    buffer += self._compile_list(data[i], indent_level+1)
                elif isinstance(data[i], list):
                    buffer += '\n'
                    buffer += self._indent * indent_level
                    buffer += self._compile_list(data[i], indent_level+1)
                else:
                    buffer += '\n'
                    buffer += self._indent * indent_level
                    buffer += self._compile_literal(data[i])

                i += 1

            return buffer
Correctly write possibly nested list.