build trees with Index and IndexEntry instead of raw manipulation