Condense some `r.expr` logic under `type` == `table`.
Allow infinite `nesting_depth` to be set.