Is it possible to determine if a componet is under a certain hierarchy?

In reply to justrajdeep:

It depends on from which context you want to ask this question. If you are in the child component, you could repeatedly call get_parent and then see if get_parent().get_name() matches what you are looking for.

However, the UVM tries to avoid dependencies that rely on hierarchical references. If lower level component want to make a decision based on which hierarchy it sits in, a better option might be to have the higher level component make a setting in the config_db for the lower level component to retrieve.