Extract nth helper functions for filters

The comments became redundant between the implementation and function
names.
Extract nth helper functions for return type and filters
Make nth helper function's variable names more verbose
Get nth's index once at the top
Helpers for converting expressions to objects/types
`first` now uses a path expression

This allows code like `(= :foo (first x))` to refine they type of `x`.
Rename FirstPE to NthPE

Since it no longer can be assumed to operate on the first item, we
also add an index identifying the item. This index is not used yet.
`second` now uses a path expression

This allows code like `(= :foo (second x))` to refine they type of `x`.
nth progress