code: function findInheritedRoles (rootRoleId, memberships) {
    const inherited = []
    const applicableMemberships = memberships.filter(m => m.roleId === rootRoleId)
    for (const membership of applicableMemberships) {
      inherited.push(
        membership.memberId,
        ...findInheritedRoles(membership.memberId, memberships)
      )
    }
    return inherited
  }
docs: inheritedRoles