I have a hierarchy in my table contacts. Each contact have column state_id which related with table contact_state (contact_id). There is a column is_top in contact_state tab