Added conditionals to handle special case display of lineage, when context is root or a top level item.
Fixed reversed clauses in get_lineage().