i think you can use locations.util.parent_child() to easily see the leaf types