Keeping those relationships directly in the A and B classes will necessarily require one or the other to be a mutable property, which certainly isn’t ideal. From a Kotlin perspective, I’d argue that it’s not the circular references that are problematic, it’s the fact that they’re mutable properties.
One alternative would be to use a 3rd structure to manage the relationships. A and B are just normal, immutable classes, while that 3rd class contains the mappings from parent-to-child, and each node can query that mapping to determine its parent, ancestors, children, etc. It’s essentially just a Graph data structure where you store nodes and edges independently of one another, or like a relational DB using an extra table for a many-to-many join.