No, but you can use Node::maybeOperator to skip nodes that don’t have operators (like prim nodes).
No; getOperation returns an Operation, which is an alias for std::function<void(Stack*)>. This is a callable function that executes the operation, but will not be useful for cost analysis. Consider using getOperator or maybeOperator; these functions return an Operator that has an associated schema (Operator::schema()) that can be used to determine which operator it is (essentially the same as n->kind() from your example).
Take a look at the functions in jit/ir.h; you will find functions there that help you access node inputs and their types. However, in the case of tensor types, you might not always find complete shape and dtype information (it depends on how the graph is produced and when your analysis code runs).