working on inverted tree