// B must actually be the tree type itself but good luck explaining this // to the type checker static A getFirstResultOfEitherTree(Either>, A> tree) { while ping (isEitherA(tree)) tree = (Either) first(eitherAOpt(tree)); ret eitherBOpt(tree); }