It is reverse foldable if it is a leaf node (re: opposite of root--only source) and if it only has the one child (no way out--re: collapsible ).
162622
function _reverse_foldable_p(node){
	var ret = false;
	if( anchor.is_leaf_node(node.id()) &&
	    ! node.subgraph() && // cannot fold if already folded into
	    anchor.get_parent_nodes(node.id()).length === 1 ){
		//console.log("is foldable: " + node.id());
		ret = true;
	    }else{
		//console.log("not foldable: " + node.id());
	    }
	// console.log("  leaf_p: " + anchor.is_leaf_node(node.id()) +
	// 	    ";  parents: " + anchor.get_parent_nodes(node.id()).length);
	return ret;
    }
270914
def searchRootOfTree(reducibleChildren: Set[LNode], nodeFromTree: LNode):
    

    while True:
        out_e = nodeFromTree.east[0].outgoingEdges
        # node has no successors
        if not out_e:
            return nodeFromTree

        nextNode = out_e[0].dsts[0].parentNode
        if nextNode in reducibleChildren:
            # can reduce node, walk the tree to root
            nodeFromTree = nextNode
        else:
            # can not reduce, return last root of tree
            return nodeFromTree
557585
@Override
    public ListT<W,T> reverse() {

        return (ListT<W,T>) FoldableTransformerSeq.super.reverse();
    }
611236
function findChildContainingNode(root, node) {
  const parentNode = node.parentNode;
  return parentNode === root ?
    node :
    findChildContainingNode(root, parentNode);
}
1359446
function isLeftEdgeOf(node, ancestor) {
  while (node && node !== ancestor) {
    if (position(node) !== 0) {
      return false;
    }
    node = node.parentNode;
  }

  return true;
}
589448
public boolean canTraverseOutsideSubtree()
  {

    if (super.canTraverseOutsideSubtree())
      return true;
    else
    {
      int n = m_args.length;

      for (int i = 0; i < n; i++)
      {
        if (m_args[i].canTraverseOutsideSubtree())
          return true;
      }

      return false;
    }
  }
1022100
function IfNode(aNode, parent, scope, owner, reverseWalker) {
    this.aNode = aNode;
    this.owner = owner;
    this.scope = scope;
    this.parent = parent;
    this.parentComponent = parent.nodeType === NodeType.CMPT
        ? parent
        : parent.parentComponent;

    this.id = guid++;
    this.children = [];

    // #[begin] reverse
    if (reverseWalker) {
        if (evalExpr(this.aNode.directives['if'].value, this.scope, this.owner)) { // eslint-disable-line dot-notation
            this.elseIndex = -1;
            this.children[0] = createReverseNode(
                this.aNode.ifRinsed,
                this,
                this.scope,
                this.owner,
                reverseWalker
            );
        }
        else {
            var me = this;
            each(aNode.elses, function (elseANode, index) {
                var elif = elseANode.directives.elif;

                if (!elif || elif && evalExpr(elif.value, me.scope, me.owner)) {
                    me.elseIndex = index;
                    me.children[0] = createReverseNode(
                        elseANode,
                        me,
                        me.scope,
                        me.owner,
                        reverseWalker
                    );
                    return false;
                }
            });
        }

        this._create();
        insertBefore(this.el, reverseWalker.target, reverseWalker.current);
    }
    // #[end]
}
489621
def unroot(self):
        
        if len(self.children)==2:
            if not self.children[0].is_leaf():
                self.children[0].delete()
            elif not self.children[1].is_leaf():
                self.children[1].delete()
            else:
                raise TreeError("Cannot unroot a tree with only two leaves")
579745
private Node tryFoldInstanceof(Node n, Node left, Node right) {
    checkArgument(n.isInstanceOf());

    // TODO(johnlenz) Use type information if available to fold
    // instanceof.
    if (NodeUtil.isLiteralValue(left, true)
        && !mayHaveSideEffects(right)) {

      Node replacementNode = null;

      if (NodeUtil.isImmutableValue(left)) {
        // Non-object types are never instances.
        replacementNode = IR.falseNode();
      } else if (right.isName()
          && "Object".equals(right.getString())) {
        replacementNode = IR.trueNode();
      }

      if (replacementNode != null) {
        n.replaceWith(replacementNode);
        reportChangeToEnclosingScope(replacementNode);
        markFunctionsDeleted(n);
        return replacementNode;
      }
    }

    return n;
  }
1063446
def collapse_parent node=:current_index
      node = row_to_node if node == :current_index
      parent = node.parent
      return if parent.nil?
      goto_parent node
      collapse_node parent
    end
1076934
def unfold(self):
        """"""
        # set all direct child blocks which are not triggers to be visible
        self._trigger.setVisible(True)
        TextBlockHelper.set_collapsed(self._trigger, False)
        for block in self.blocks(ignore_blank_lines=False):
            block.setVisible(True)
            if TextBlockHelper.is_fold_trigger(block):
                TextBlockHelper.set_collapsed(block, False)
981435
Node tryFoldDoAway(Node n) {
    checkArgument(n.isDo());

    Node cond = NodeUtil.getConditionExpression(n);
    if (NodeUtil.getImpureBooleanValue(cond) != TernaryValue.FALSE) {
      return n;
    }

    Node block = NodeUtil.getLoopCodeBlock(n);
    if (n.getParent().isLabel() || hasUnnamedBreakOrContinue(block)) {
      return n;
    }

    Node parent = n.getParent();
    n.replaceWith(block.detach());
    if (mayHaveSideEffects(cond)) {
      Node condStatement = IR.exprResult(cond.detach()).srcref(cond);
      parent.addChildAfter(condStatement, block);
    }
    reportChangeToEnclosingScope(parent);

    return block;
  }
165005
function TemplateNode(aNode, parent, scope, owner, reverseWalker) {
    this.aNode = aNode;
    this.owner = owner;
    this.scope = scope;
    this.parent = parent;
    this.parentComponent = parent.nodeType === NodeType.CMPT
        ? parent
        : parent.parentComponent;

    this.id = guid++;
    this.lifeCycle = LifeCycle.start;
    this.children = [];

    // #[begin] reverse
    if (reverseWalker) {
        this.sel = document.createComment(this.id);
        insertBefore(this.sel, reverseWalker.target, reverseWalker.current);

        var me = this;
        each(this.aNode.children, function (aNodeChild) {
            me.children.push(createReverseNode(aNodeChild, me, me.scope, me.owner, reverseWalker));
        });

        this.el = document.createComment(this.id);
        insertBefore(this.el, reverseWalker.target, reverseWalker.current);

        this.lifeCycle = LifeCycle.attached;
    }
    // #[end]
}
927410
function pickReverseEach( reverse, node, callback ) {
        var test = type.call( node, 'Undefined' ) ||
            node==='false' ||
            node===false ||
            (
                type.call( node, 'Boolean' ) && 
                !node.valueOf()
            );

        if ( test ) {
            pickReverse.call( this, reverse, true, callback );
        }
        else if ( type.call( node.isBoolean, 'Function' ) ) {
            if ( node.isBoolean.tick ) {

            }
            else {
                pickReverse.call( this, reverse, ( ( node.isBoolean() && !node.valueOf() ) || !node ), callback );
            }
        }
        else {
            pickReverse.call( this, reverse, !node, callback );
        }
    }
23041
def is_leaf(self):
        
        return (not self.data) or \
               (all(not bool(c) for c, p in self.children))
993293
function findParentContentEditable(node) {
          var parent = node;

          while (parent) {
            if (parent.nodeType === 1 && getContentEditable(parent)) {
              return getContentEditable(parent) === "false" ? parent : node;
            }

            parent = parent.parentNode;
          }

          return node;
        }
479370
function undo(nodes) {
  nodes.forEach(function (node) {
    var parent = node.parentNode
    unwrap(node)
    parent.normalize()
  })
}