code: func NewPathForRef(ref ast.Ref) (path Path, err error) {
  
  	if len(ref) == 0 {
  		return nil, fmt.Errorf("empty reference (indicates error in caller)")
  	}
  
  	if len(ref) == 1 {
  		return Path{}, nil
  	}
  
  	for _, term := range ref[1:] {
  		switch v := term.Value.(type) {
  		case ast.String:
  			path = append(path, string(v))
  		case ast.Number:
  			path = append(path, v.String())
  		case ast.Boolean, ast.Null:
  			return nil, &Error{
  				Code:    NotFoundErr,
  				Message: fmt.Sprintf("%v: does not exist", ref),
  			}
  		case ast.Array, ast.Object, ast.Set:
  			return nil, fmt.Errorf("composites cannot be base document keys: %v", ref)
  		default:
  			return nil, fmt.Errorf("unresolved reference (indicates error in caller): %v", ref)
  		}
  	}
  
  	return path, nil
  }
docs: // NewPathForRef returns a new path for the given ref.