If this is a tree, are you sure you need Rc<RefCell>
and dynamic borrowing? Wouldn't you be able to just use Box
? (Here's an earlier answer of mine to a different question where OP also needed to build a tree level by level, you can check how I solved that.)