How do I show something only for a parent segment and not it's children? How do I display something only for one of the parent Structure sections and not others or this sections children?
I was thinking of using

{% if craft.request.segment(2) == 'modules' and craft.request.lastSegment|length %}''


but that still shows for its children.
The lastSegment will always have length whether it's 2, 3, 4 etc. I am unclear about your Structure setup, but if there is nothing after "modules", "modules" is the last segment and therefore exists.

So maybe something like:

{% if craft.request.getSegment(2) == 'modules' and not craft.request.getSegment(3)|length %}