Check if walls are placed on top of each other

I am trying to find a way how to check if two walls are placed on each other and, eventually, filter out top ones.

So far I have no clue in which direction to look. Idea I had is to extract top and bottom surfaces of each wall and see if they have same location (maybe by curves?). The issue with this workflow I can imagine is situations, when geometry of walls is different, e.g. surfaces will not be totally laying on each other (see snapshot for illustration).

Any suggestions where I should look? Thanks!