Create a nested structure based on flat object key names