JavaScript (ES6), 268263 bytes
s=>s.replace(/\S+/g,v=>v>{}?s[0][1]=[[v,1]]:s=[[(u=[])|v||([[y,q],[x,u],...s]=s,S=v<"/"||-1,v+1|0?e|=u+''!=q:q.map(([U,e])=>(o=uu.find(o=>o[0]==U))?o[1]+=e*S:u||u.push([Uo=[U,e*S]0])&&o)[1]+=v<"/"?e:-e),eval(x+v+y)),u.filter(o=>o[1]).sort()],...s],e=s=[])|e?"*":s.reverse().join` `.split`,`.join``