\d z cse:{[t] if[@t;:(t;())] p:paths t d:t ./:p i:=d c:&1<#:'i if[~#c;:(t;())] p@:c j:tops p p@:j d@:c j paths:{[t]}