Recursively finds the operands under `parentOp` in the input tree `node`. The input tree `node` will always have a parent that is an operation of type `op`. Op is a string e.g. '+' or '*' returns the list of all the node operated on by `parentOp`
175338
function getOperands(node, parentOp) {
  // We can only recurse on operations of type op.
  // If the node is not an operator node or of the right operation type,
  // we can't break up or flatten this tree any further, so we return just
  // the current node, and recurse on it to flatten its ops.
  if (!Node.Type.isOperator(node)) {
    return [flattenOperands(node)];
  }
  switch (node.op) {
  // division is part of flattening multiplication
  case '*':
  case '/':
    if (parentOp !== '*') {
      return [flattenOperands(node)];
    }
    break;
  case '+':
  case '-':
    if (parentOp !== '+') {
      return [flattenOperands(node)];
    }
    break;
  default:
    return [flattenOperands(node)];
  }
  if (Node.PolynomialTerm.isPolynomialTerm(node, true)) {
    node.args.forEach((arg, i) => {
      node.args[i] = flattenOperands(node.args[i]);
    });
    return [node];
  }

  // If we're flattening over *, check for a polynomial term (ie a
  // coefficient multiplied by a symbol such as 2x^2 or 3y)
  // This is true if there's an implicit multiplication and the right operand
  // is a symbol or a symbol to an exponent.
  else if (parentOp === '*' && isPolynomialTermMultiplication(node)) {
    return maybeFlattenPolynomialTerm(node);
  }
  else if (parentOp === '*' && node.op === '/') {
    return flattenDivision(node);
  }
  else if (node.op === '-') {
    // this operation will become addition e.g. 2 - 3 -> 2 + -(-3)
    const secondOperand = node.args[1];
    const negativeSecondOperand = Negative.negate(secondOperand, true);
    const operands = [
      getOperands(node.args[0], parentOp),
      getOperands(negativeSecondOperand, parentOp)
    ];
    return [].concat.apply([], operands);
  }
  else {
    const operands = [];
    node.args.forEach((child) => {
      // This will make an array of arrays
      operands.push(getOperands(child, parentOp));
    });
    return [].concat.apply([], operands);
  }
}
334751
function() {
                var m, a, op, operation;
                m = $(this.operand);
                if (m) {
                    while ((op = ($('/') || $('*') || $('%'))) && (a = $(this.operand))) {
                        operation = new tree.Operation(op, [operation || m, a], memo, env.filename);
                    }
                    return operation || m;
                }
            }
283723
def expr(self):
        
        node = self.term()

        while self.token.nature in (Nature.PLUS, Nature.MINUS):
            token = self.token
            if token.nature == Nature.PLUS:
                self._process(Nature.PLUS)
            elif token.nature == Nature.MINUS:
                self._process(Nature.MINUS)
            else:
                self._error()

            node = BinaryOperation(left=node, op=token, right=self.term())

        return node
1056542
def get_tree(cls, parent=None):
        
        if parent:
            depth = parent.get_depth() + 1
            results = [parent]
        else:
            depth = 1
            results = []
        cls._get_tree_recursively(results, parent, depth)
        return results
1072323
private Node findParentNode(long node) {
        // assert node > 0;

        // find bit representation of node
        long[] s = { node };
        BitSet bits = BitSet.valueOf(s);

        // traverse path to last node
        Node cur = root;
        for (int i = bits.length() - 2; i > 0; i--) {
            if (bits.get(i)) {
                cur = cur.o_c.y_s;
            } else {
                cur = cur.o_c;
            }
        }
        return cur;
    }
530000
function getParentNode(node) {
  return genericPropertyGet(
      Methods.PARENT_NODE_GETTER, node, 'parentNode', function(parentNode) {
        // We need to ensure that parentNode is returning the actual parent node
        // and not a child node that happens to have a name of "parentNode".
        // We check that the node returned by parentNode is itself not named
        // "parentNode" - this could happen legitimately but on IE we have no
        // better means of avoiding the pitfall.
        return !(
            parentNode && typeof parentNode.name == 'string' &&
            parentNode.name && parentNode.name.toLowerCase() == 'parentnode');
      });
}
1034386
public static String parent(String node) {
        final int index = node.lastIndexOf('/');
        if (index < 0)
            return null;
        return node.substring(0, index);
    }
354239
function() {
    var op
      , node = this.defined();
    while (op =
         this.accept('**')
      || this.accept('*')
      || this.accept('/')
      || this.accept('%')) {
      this.operand = true;
      if ('/' == op && this.inProperty && !this.parens) {
        this.stash.push(new Token('literal', new nodes.Literal('/')));
        this.operand = false;
        return node;
      } else {
        if (!node) this.error('illegal unary "' + op + '", missing left-hand operand');
        node = new nodes.BinOp(op.type, node, this.defined());
        this.operand = false;
      }
    }
    return node;
  }
906140
function find(obj, node, parent) {
  if (!obj) return;
  var result;

  var types = Object.keys(obj);
  for (var i = 0; i < types.length; i++) {
    var type = types[i];

    if (t.is(type, node)) {
      var fn = obj[type];
      result = fn(node, parent);
      if (result != null) break;
    }
  }

  return result;
}
1022111
def relation_operation(self):
        
        if len(self.nodes) > 0:
            rel_op = self.nodes[-1].relation_operation
        else:
            rel_op = None
        return rel_op
1297962
def _get_node_parent(self, age, pos):
        
        return self.nodes[age][int(pos / self.comp)]
481058
def best_parent( self, node, tree_type=None ):
        """"""
        parents = self.parents(node)
        selected_parent = None
        if node['type'] == 'type':
            module = ".".join( node['name'].split( '.' )[:-1] )
            if module:
                for mod in parents:
                    if mod['type'] == 'module' and mod['name'] == module:
                        selected_parent = mod 
        if parents and selected_parent is None:
            parents.sort( key = lambda x: self.value(node, x) )
            return parents[-1]
        return selected_parent
592681
def _check_operator(self, operator):
        

        if not isinstance(operator, type(None)):
            tree = [obj.__name__ for obj in getmro(operator.__class__)]

            if not any([parent in tree for parent in self._op_parents]):
                warn('{0} does not inherit an operator '
                     'parent.'.format(str(operator.__class__)))
596728
def t_op(self, s):
        '

        # Operators need to be further classified since the grammar requires this
        if s in ('<', '>', '==', '>=', '<=', '<>', '!='):
            self.add_token('COMP_OP', s)
        elif s in ('+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '**=',
                   '//='):
            self.add_token('AUGASSIGN', s)
        elif s in self.UNOP2NAME.keys():
            self.add_token(self.UNOP2NAME[s], s)
        elif s in ('|', '^', '&', '<<', '>>', '**', '/', '%', '//'):
            # These are  *ONLY* binary operators. Operators which are exclusively or
            # can be unary operators were handled previously
            self.add_token('BINOP', s)
        elif s == '=':
            self.add_token('EQUAL', s)
        else:
            print("Internal error: Unknown operator %s" % s)
            raise SystemExit
875705
function isParentNodeType(parent, nodeType) {
            return parent.type === nodeType ||
                (parent.body && parent.body.type === nodeType) ||
                (parent.consequent && parent.consequent.type === nodeType);
        }
1205560
function getParentheses() {
  const type = NodeType.ParenthesesType;
  const token = tokens[pos];
  const line = token.ln;
  const column = token.col;
  const right = token.right;
  let content = [];

  // Skip `(`.
  pos++;

  if (pos < right) {
    content = getTsets();
  }

  const end = getLastPosition(content, line, column, 1);

  // Skip `)`.
  pos++;

  return newNode(type, content, line, column, end);
}
611032
public static int computeIndexInParent(Object nodeObject)
    {
        if (nodeObject instanceof DefaultMutableTreeNode)
        {
            DefaultMutableTreeNode node = 
                (DefaultMutableTreeNode)nodeObject;
            TreeNode parent = node.getParent();
            if (parent == null)
            {
                return -1;
            }
            int childCount = parent.getChildCount();
            for (int i=0; i<childCount; i++)
            {
                TreeNode child = parent.getChildAt(i);
                if (child == nodeObject)
                {
                    return i;
                }
            }
        }
        return -1;
    }