if current stack is a choice's branch,return the original parent stack
359309
function endChoice(stack) {
    if (stack._parentChoice) {
      var choice=stack._parentChoice;
      delete stack._parentChoice;
      delete stack._parentGroup;
      delete stack.groupCounter;
      var parentStack=choice._parentStack;
      delete choice._parentStack;
      
      return parentStack;
    }
    return stack;
  }
846625
def find_parent_scope(block):
        """"""
        original = block
        if not TextBlockHelper.is_fold_trigger(block):
            # search level of next non blank line
            while block.text().strip() == '' and block.isValid():
                block = block.next()
            ref_lvl = TextBlockHelper.get_fold_lvl(block) - 1
            block = original
            while (block.blockNumber() and
                   (not TextBlockHelper.is_fold_trigger(block) or
                    TextBlockHelper.get_fold_lvl(block) > ref_lvl)):
                block = block.previous()
        return block
77683
def get_stack_info():
    '''
    '''
    stack = traceback.walk_stack(sys._getframe().f_back)

    # We want locals from the test definition (which always begins
    # with 'test_' in unittest), which will be at a different
    # level in the stack depending on how many tests are in each
    # test case, how many test cases there are, etc.

    # The branch where we exhaust this loop is not covered
    # because we always find a test.
    for frame, _ in stack:  # pragma: no branch
        code = frame.f_code
        if code.co_name.startswith('test_'):
            return (frame.f_locals.copy(), frame.f_globals['__name__'],
                    code.co_filename, frame.f_lineno)
63573
def top_parent(self):
        
        parent = self.parent
        while parent is not None:
            if parent.parent is None:
                return parent
            else:
                parent = parent.parent
        return self
808618
def os_forkpty_wrapper():
    """"""
    pid = None
    prepare_to_fork_acquire()
    try:
        pid, fd = _orig_os_forkpty()
    finally:
        if pid == 0:
            child_after_fork_release()
        else:
            parent_after_fork_release()
    return pid, fd
1201139
ObjectType findCommonSuperObject(ObjectType a, ObjectType b) {
    List<ObjectType> stackA = getSuperStack(a);
    List<ObjectType> stackB = getSuperStack(b);

    ObjectType result = getNativeObjectType(JSTypeNative.OBJECT_TYPE);
    while (!stackA.isEmpty() && !stackB.isEmpty()) {
      ObjectType currentA = stackA.remove(stackA.size() - 1);
      ObjectType currentB = stackB.remove(stackB.size() - 1);
      if (currentA.isEquivalentTo(currentB)) {
        result = currentA;
      } else {
        return result;
      }
    }
    return result;
  }
861667
def has_stack(self, s):
        """"""
        for t in self.transitions:
            if t.lhs[s].position != 0:
                return False
            if t.rhs[s].position != 0:
                return False
        return True
538761
def get_parent_scope_from_var(name, global_ok=False, skip_frames=0) -> typing.Optional[Scope]:
    

    stack = inspect.stack()
    try:
        for frame_info in stack[skip_frames + 1:]:
            frame = None

            try:
                frame = frame_info.frame

                if name in frame.f_locals or (global_ok and name in frame.f_globals):
                    return Scope(globals_=frame.f_globals, locals_=frame.f_locals)
            finally:
                del frame
    finally:
        del stack

    return None
275160
def get_parent_var(name, global_ok=False, default=None, skip_frames=0):
    

    scope = get_parent_scope_from_var(name, global_ok=global_ok, skip_frames=skip_frames + 1)

    if not scope:
        return default

    if name in scope.locals:
        return scope.locals.get(name, default)

    return scope.globals.get(name, default)
1105241
def _closure_parent_pk(self):
        """"""
        if hasattr(self, "%s_id" % self._closure_parent_attr):
            return getattr(self, "%s_id" % self._closure_parent_attr)
        else:
            parent = getattr(self, self._closure_parent_attr)
            return parent.pk if parent else None
34885
function(branch, category, appName) {

  // Validate.
  if (!isBranch(branch)) {
    throw new TypeError('Invalid branch: ' + pp(branch));
  }

  // Recursively map branch to get the cli look we want.
  var recMap = function(node) {

    if (isTask(node)) {

      // This is a task so do nothing.
      return [node];

    } else if (isBranch(node)) {

      // Concat map children with a recMap.
      node.children = _.flatten(_.map(node.children, recMap));

      // Sort children.
      node.children.sort(compareBranchOrTask);

      // Resolve duplicate named children.
      // Group children by name.
      var nameMap = _.groupBy(node.children, getName);

      // Resolve conflicts.
      node.children = _.map(_.values(nameMap), function(children) {

        if (children.length === 1) {

          // No conflicts so just return head of array.
          return children[0];

        } else {

          // Resolve conflict by finding a single node with the override flag.
          var overrides = _.filter(children, function(child) {
            return child.__override;
          });

          if (overrides.length === 1) {

            // Conflict resolved.
            return overrides[0];

          } else {

            // Conflict can not be resolved, throw an error.
            throw new Error('Conflicting task names can not be resolved: ' +
              pp(children));

          }

        }

      });

      if (getName(node) === appName) {

        // Replace this node with this nodes children.
        _.each(node.children, function(child) {
          // Mark each child with an override flag so we can resolve conflicts.
          child.__override = true;
        });
        return node.children;

      } else {

        // Just return.
        return [node];

      }

    } else {

      // This should never happen.
      assert(false);

    }

  };

  // Recursively build list of lines.
  var recAdd = function(node, lines, parentName, depth) {

    // Default depth.
    if (_.isUndefined(depth)) {
      depth = 0;
    }

    // Default parentName.
    if (_.isUndefined(parentName)) {
      parentName = 'root';
    }

    if (isTask(node)) {

      // This is a task so add to lines and nothing further.
      lines.push({
        depth: depth,
        name: getName(node),
        parentName: parentName,
        description: node.description
      });

    } else if (isBranch(node)) {

      lines.push({
        depth: depth,
        name: getName(node),
        parentName: parentName
      });
      node.children.forEach(function(child) {
        recAdd(child, lines, getName(node), depth + 1);
      });

    } else {

      // This should never happen.
      assert(false);

    }

  };

  // Only do this is branch is not the app branch.
  if (getName(branch) !== appName) {
    branch = recMap(branch)[0];
  }

  // Filter by correct category
  var kids = _.filter(branch.children, function(child) {
    // Go one level deeper if we are on a branch and
    // want to find the category of its children
    if (child.category === undefined) {
      if (!_.isEmpty(child.children)) {
        return child.children[0].category === category;
      }
    }
    else {
      return child.category === category;
    }
  });

  if (!_.isEmpty(kids)) {
    // Number of spaces sub commands will be indented.
    var tabSpacing = 4;

    // Header for menu.
    var header = '\n' + catDesc[category];

    // Init list of lines.
    var lines = [];

    kids.forEach(function(child) {
      recAdd(child, lines);
    });

    lines = _.map(lines, function(line) {
      var depthPrefix = _.repeat(' ', tabSpacing * line.depth + 2);
      var name = depthPrefix + line.name;
      return {
        name: name,
        description: line.description
      };
    });

    /*
    var widths = _.map(lines, function(line) {
      return line.name.length;
    });
    */
    var maxWidth = 15;

    lines = _.map(lines, function(line) {
      var name = _.padRight(line.name, maxWidth);
      if (line.description) {
        return [
          chalk.green(name),
          chalk.yellow(line.description)
        ].join(_.repeat(' ', tabSpacing));
      } else {
        return chalk.green(name);
      }
    });

    lines.unshift(header);
    return lines.join('\n');
  }
}
1352566
def pop(self):
        

        if self.stack:
            val = self.stack[0]
            self.stack = self.stack[1:]
            return val
        else:
            raise StackError('Stack empty')
85223
private Node tryFoldHook(Node n) {
    checkState(n.isHook(), n);
    Node parent = n.getParent();
    checkNotNull(parent);
    Node cond = n.getFirstChild();
    Node thenBody = cond.getNext();
    Node elseBody = thenBody.getNext();

    TernaryValue condValue = NodeUtil.getImpureBooleanValue(cond);
    if (condValue == TernaryValue.UNKNOWN) {
      // If the result nodes are equivalent, then one of the nodes can be
      // removed and it doesn't matter which.
      if (!areNodesEqualForInlining(thenBody, elseBody)) {
        return n;  // We can't remove branches otherwise!
      }
    }

    // Transform "(a = 2) ? x =2 : y" into "a=2,x=2"
    Node branchToKeep;
    Node branchToRemove;
    if (condValue.toBoolean(true)) {
      branchToKeep = thenBody;
      branchToRemove = elseBody;
    } else {
      branchToKeep = elseBody;
      branchToRemove = thenBody;
    }

    Node replacement;
    boolean condHasSideEffects = mayHaveSideEffects(cond);
    // Must detach after checking for side effects, to ensure that the parents
    // of nodes are set correctly.
    n.detachChildren();
    if (condHasSideEffects) {
      replacement = IR.comma(cond, branchToKeep).srcref(n);
    } else {
      replacement = branchToKeep;
      markFunctionsDeleted(cond);
    }

    parent.replaceChild(n, replacement);
    reportChangeToEnclosingScope(replacement);
    markFunctionsDeleted(branchToRemove);
    return replacement;
  }
124184
def get_node_parent_class(node):
    """"""

    while node.parent:  # pragma no branch
        if isinstance(node, ClassDef):
            return node

        node = node.parent
497975
def _get_or_create_stack(name):
  """"""
  stack = getattr(_LOCAL_STACKS, name, None)
  if stack is None:
    stack = []
    setattr(_LOCAL_STACKS, name, stack)
  return stack
481193
def bsp_father(node: tcod.bsp.BSP) -> Optional[tcod.bsp.BSP]:
    
    return node.parent
362690
def get_single_stack(self):
        """"""

        single = None
        while self.single_stack:
            single = self.single_stack.pop()
        return single