/** * @param tree * @return */ @Pure @ExtensionMethod @ReturnNonnull @Recursive public static <T> AbstractUnmodifiableIterable<T> NodeValuesPostOrder(final IMultiTree<T> tree) { com.google.common.base.Preconditions.checkNotNull(tree); if (tree.IsTreeNode()) { final IMultiTreeNode<T> treeNode = tree.AsTreeNode(); assert treeNode != null; return Iterables.Concat( Iterables.Concat( Iterables.Map( treeNode.GetSubtrees(), new Func1<IMultiTree<T>, Iterable<T>>() { @Override public Iterable<T> DoFunc(final IMultiTree<T> input) { assert input != null; return MultiTrees.NodeValuesPreOrder(input); } })), treeNode.GetNodeValue()); } else { assert tree.IsEmptyTree(); return Iterables.EmptyUnmodifiableIterable(); } }
/** * @param tree * @return */ @SuppressWarnings("unchecked") @Pure @CheckForNull @ExtensionMethod public static <T> IMultiTreeNode<T> AsMultiTreeNodeWhenReadOnly( @Nullable final IMultiTree<? extends T> tree) { return MultiTrees.SafeCastWhenReadOnly(tree.AsTreeNode()); }