How to split walls per selected Level?

Is it possible to edit the Python code in such way it works with walls who are unconstrained?
Or in other words; walls without a top constraint.