Refactor to allow arbitrarily-deep nesting of parent-child rels