In Python, I'm going to write a bunch of rules that prints out the "highest order" in a tree hierarchy.
level_1 = "Trunk"
level_2 = "Branch"
level_3 = "Leaf"
if level_3 is not None:
elif level_2 is not None:
elif level_1 is not None:
for msj in (level_3,level_2,level_1): if msj: print msj break
or a variation to Reut solution
msj = level_3 or level_2 or level_1 if msj: print msj
both solution will print the first non-empty and non-None element they come across