various refactoring and bug fix in BMM_SCHEMA.is_descendant