def iter_headings(paragraphs):
    for paragraph in paragraphs:
        if startswith(paragraph.style.name, 'Heading'):
            yield paragraph
for heading in iter_headings(document.paragraphs):
    pass
Extracting headings' text from word doc