let upper_is_or cycle tree =
    let rec up_or cyc =
      match cyc with
        x::tail -> if is_OR x tree then true else (if is_MUX x tree then false else up_or tail)
      | _ -> false
    in up_or (List.tl (List.rev cycle))