I'm creating a property theme and I have a hierarchical taxonomy 'property_location' registered for the custom post type 'property'. Each property will be assigned a location through this tax, which may have one or more parents in a hierarchical fashion. So for instance if I assign the location term of 'Springs' to a property, which is a child term of 'Gauteng', it should give me
Springs, Gauteng
And if Gauteng happens to be a child term of 'South Africa', it should give me
Springs, Gauteng, South Africa
But if I just assign the 'Gauteng' term (assuming it is a child term of the 'South Africa' term, it should give me
Gauteng, South Africa
So my question is how would I write a function smart enough to find the lowest level location term assigned to a property and get its parent terms in order? Is there any Wordpress functions that would help?