pass tests for nested expressions with stack algorithm