Might simplify your code to have `traverseAllChildren` call `traverseAllChildrenImpl` with `nameSoFar` of `SEPARATOR` (and check `isOnlyChild = nameSoFar === SEPARATOR` here). Might not be that much better though.