Determine shape of nested lists