Use stack to track item contexts.