refactor to having a tagstack and a root
Shared parent/child handling