let upper_or_edge cycle tree =
let back_in = List.hd (List.rev cycle)
in
let rec upper cyc=
match cyc with
x::t::tail ->if is_OR x tree
then let filterid = (edgefilter tree (fun _ mx -> let (cx,tx,_)=mx.edge in tx ==t && cx.sourceid == x && mx.edgeway == Normal))
in (List.hd (List.map (fun nx -> let (cx,_,_) = nx.edge in cx.nameforudg) filterid))
else upper (t::tail)
| x::tail -> if is_OR x tree
then let filterid = (edgefilter tree (fun _ mx -> let (cx,tx,_)=mx.edge in tx ==back_in && cx.sourceid == x && mx.edgeway == Backward))
in (List.hd (List.map (fun nx -> let (cx,_,_) = nx.edge in cx.nameforudg) filterid))
else upper tail
| _ -> NewName.invalid_id
in
upper (List.tl (List.rev cycle))