recursively_define_namespace method