shouldn't that be
if(parent == NULL || parent->children == NULL) {
in get_swayc_for_handle ? if(parent == NULL || parent->children == NULL) {
in get_swayc_for_handle ?