Add scope kind and outer scope calculation helper