Fixpoint rgopher (s: tree) : tree :=
match s with
| EE => EE
| T _ sl k sr => match rgopher sr with
| T _ srl j srr => T Red  (T Red sl k srl) j srr
| EE => s
end
end.

Lemma shape_rgopher: forall a,
match rgopher a with
| T _ _ _ (T _ _ _ _) => False
| _ => True
end.