Working implementation of building the tree of frame parents to children recursively