Gooey recursiveness.
18219
private void printDatabase(Account acc, int level, PrintStream stream) {
        String buf = "";

        for (int i = 0; i < level; i++)
            buf += " ";

        buf += "+";
        buf += acc.getName() + "[" + acc.getUrl() + "] (" + acc.getPatterns().size() + " patterns)";

        stream.println(buf);

        for (Account account : acc.getChildren())
            printDatabase(account, level + 2, stream);
    }

    public List<Account> findPathToAccountById(String id) {
        LinkedList<Account> result = getRootInLinkedList();
        findAccountById(result, id);
        // reverse the list, so that its,<root> -> parent -> ... -> Found Account
        List<Account> retValue = new ArrayList<Account>(result.size());
        Iterator<Account> iter = result.descendingIterator();
        while (iter.hasNext()) retValue.add(iter.next());
        return retValue;
    }

    public List<Account> getAllAccounts() {
        Set<Account> acc = new HashSet<Account>();
        getAllAccounts(getRootAccount(), acc);
        List<Account> sorted = new ArrayList<Account>(acc);
        Collections.sort(sorted, new Comparator<Account>() {
            @Override
            public int compare(Account o1, Account o2) {
                return o1.getName().compareToIgnoreCase(o2.getName());
            }
        });
        return sorted;
    }

    private void getAllAccounts(Account base, Collection<Account> into) {
        for (Account c : base.getChildren()) {
            if ( c.hasChildren() ) {
                getAllAccounts(c, into);
            } else {
                into.add(c);
            }
        }
    }


    /**
     * Locates an account, given an id.
     *
     * @param id The account id (unique hash).
     * @return The account if found, else null.
     */
    public Account findAccountById(String id) {
        return findAccountById(getRootInLinkedList(), id);
    }

    /**
     * Internal function to recurse through accounts looking for an id.
     *
     * @param stack  The path to the current parent
     * @param id     The id to look for.
     * @return The Account if found, else null.
     */
    private Account findAccountById(LinkedList<Account> stack, String id) {
        final Account parent = stack.peek();
        if (parent == null) {
            if ( ! stack.isEmpty() ) stack.pop();
            return null;
        }
        for (Account child : parent.getChildren()) {
            if (child.getId().equals(id)) {
                stack.push(child);
                return child;
            }
            if (child.getChildren().size() > 0) {
                stack.push(child);
                Account foundAccount = findAccountById(stack, id);
                if (foundAccount != null)
                    return foundAccount;
            }
        }
        stack.pop();
        return null;
    }

    private LinkedList<Account> getRootInLinkedList() {
        LinkedList<Account> stack = new LinkedList<Account>();
        stack.add(rootAccount);
        return stack;
    }

    /**
     * Searches the database for any account with a matching URL.
     *
     * @param url The regex to search with.
     * @return The account if found, else null.
     */
    public Account findAccountByUrl(String url) {
        return findAccountByUrl(rootAccount, url);
    }

    /**
     * Internal function to aid in searching.  This will find the first account in the tree starting at parent
     * that matches the url given.
     *
     * @param parent - The parent to start searching with.
     * @param url    - Url to search for
     * @return the matching account (maybe the parent), or Null if no matching account was found.
     */
    private Account findAccountByUrl(Account parent, String url) {
        // First search the parent
        if (AccountPatternMatcher.matchUrl(parent, url) && !parent.isRoot())
            return parent;
        for (Account child : parent.getChildren()) {
            Account foundAccount = findAccountByUrl(child, url);
            if (foundAccount != null)
                return foundAccount;
        }
        return null;
    }
1133089
private static <V> TreeEntry<V> successor(TreeEntry<V> t) {
        if (t == null) {
            return null;
        } else if (t.right != null) {
            TreeEntry<V> p = t.right;
            while (p.left != null) {
                p = p.left;
            }
            return p;
        } else {
            TreeEntry<V> p = t.parent;
            TreeEntry<V> ch = t;
            while (p != null && ch == p.right) {
                ch = p;
                p = p.parent;
            }
            return p;
        }
    }
291575
private static int recursiveFindStraddle(final double[] xArr, final int left, final int right,
      final double x) {
    final int middle;
    assert (left < right);
    assert ((xArr[left] <= x) && (x < xArr[right])); /* the invariant */
    if ((left + 1) == right) {
      return (left);
    }
    middle = left + ((right - left) / 2);
    if (xArr[middle] <= x) {
      return (recursiveFindStraddle(xArr, middle, right, x));
    } else {
      return (recursiveFindStraddle(xArr, left, middle, x));
    }
  }
844480
function _gpfPow2 (n) {
    var result = _gpfPow2[n];
    if (result) {
        return result;
    }
    result = _gpfComputePow2(n);
    _gpfPow2[n] = result;
    return result;
}
187406
def recursive_iter(enumerables):
    '''
    
    '''
    if not is_collection(enumerables) or isinstance(enumerables, (basestring, dict)):
        yield enumerables
    else:
        for elem in enumerables:
            for sub_elem in recursive_iter(elem):
                yield sub_elem
505121
function(T, C, n, k) {
        var i;
        for (i = 0; i < k; i++) { C[i] = 0; }
        for (i = 0; i < n; i++) { C[T[i]]++; }
    }
121059
def _recursive_round(self, value, precision):
        
        if hasattr(value, '__iter__'):
            return tuple(self._recursive_round(v, precision) for v in value)
        return round(value, precision)
1277501
private MutableBigInteger binaryGCD(MutableBigInteger v) {
        // Algorithm B from Knuth section 4.5.2
        MutableBigInteger u = this;
        MutableBigInteger r = new MutableBigInteger();

        // step B1
        int s1 = u.getLowestSetBit();
        int s2 = v.getLowestSetBit();
        int k = (s1 < s2) ? s1 : s2;
        if (k != 0) {
            u.rightShift(k);
            v.rightShift(k);
        }

        // step B2
        boolean uOdd = (k == s1);
        MutableBigInteger t = uOdd ? v: u;
        int tsign = uOdd ? -1 : 1;

        int lb;
        while ((lb = t.getLowestSetBit()) >= 0) {
            // steps B3 and B4
            t.rightShift(lb);
            // step B5
            if (tsign > 0)
                u = t;
            else
                v = t;

            // Special case one word numbers
            if (u.intLen < 2 && v.intLen < 2) {
                int x = u.value[u.offset];
                int y = v.value[v.offset];
                x  = binaryGcd(x, y);
                r.value[0] = x;
                r.intLen = 1;
                r.offset = 0;
                if (k > 0)
                    r.leftShift(k);
                return r;
            }

            // step B6
            if ((tsign = u.difference(v)) == 0)
                break;
            t = (tsign >= 0) ? u : v;
        }

        if (k > 0)
            u.leftShift(k);
        return u;
    }
1184568
def recursive_index_decode(int_array, max=32767, min=-32768):
    """"""
    out_arr = []
    encoded_ind = 0
    while encoded_ind < len(int_array):
        decoded_val = 0
        while int_array[encoded_ind]==max or int_array[encoded_ind]==min:
            decoded_val += int_array[encoded_ind]
            encoded_ind+=1
            if int_array[encoded_ind]==0:
                break
        decoded_val += int_array[encoded_ind]
        encoded_ind+=1
        out_arr.append(decoded_val)
    return out_arr
201969
def is_recursive(self, child_item):
        """"""
        ancestor = child_item.parent()
        # FIXME: indexes to data should be defined by a dictionary on init
        while ancestor:
            if (child_item.data(0, Qt.DisplayRole
                                ) == ancestor.data(0, Qt.DisplayRole) and
                child_item.data(7, Qt.DisplayRole
                                ) == ancestor.data(7, Qt.DisplayRole)):
                return True
            else:
                ancestor = ancestor.parent()
        return False
585804
private void mmuli(int n, double[] A, double[] B, double[] C) {
        for (int i = 0; i < n * n; i++) {
            C[i] = 0;
        }

        for (int j = 0; j < n; j++) {
            int jn = j * n;
            for (int k = 0; k < n; k++) {
                int kn = k * n;
                double bkjn = B[k + jn];
                for (int i = 0; i < n; i++) {
                    C[i + jn] += A[i + kn] * bkjn;
                }
            }
        }
    }
345509
def recursive_children(self):
        

        for child in self.children:
            yield child

            for recursive_child in child.recursive_children:
                yield recursive_child
1354269
private Collection<? extends String> recursiveCollect(String refId,
      Map<String, SortedSet<String>> relationKeyMap, int maxRecursion) {
    Set<String> list = new HashSet<>();
    if (maxRecursion > 0 && relationKeyMap.containsKey(refId)) {
      SortedSet<String> subList = relationKeyMap.get(refId);
      for (String subRefId : subList) {
        list.add(subRefId);
        list.addAll(
            recursiveCollect(subRefId, relationKeyMap, maxRecursion - 1));
      }
    }
    return list;
  }
1310764
void rot(int n, int[] xy, int rx, int ry) {
        if (ry == 0) {
            if (rx == 1) {
                xy[0] = n - 1 - xy[0];
                xy[1] = n - 1 - xy[1];
            }
            int t = xy[0];
            xy[0] = xy[1];
            xy[1] = t;
        }
    }
1083085
private int rankPermutationLexicographically(int[] permutation) {
        int rank = 0;
        int n = permutation.length;
        int[] counter = new int[n + 1];
        for (int i = 1; i < permutation.length; i++) {
            counter[i] = permutation[i - 1] + 1;
        }
        for (int j = 1; j <= n; j++) {
            rank += (counter[j] - 1) * factorial(n - j);
            for (int i = j + 1; i <= n; i++) {
                if (counter[i] > counter[j]) {
                    counter[i]--;
                }
            }
        }
        return rank + 1;
    }
567485
def _ttr(self, k, dist, cache):
        """"""
        a,b = evaluation.evaluate_recurrence_coefficients(dist, k)
        return -a, b
1301435
private void recursiveLogResult(StringBuilder buf, Hierarchy<Result> hier, Result result, int depth) {
    if(result == null) {
      buf.append("null");
      LOG.warning("null result!");
      return;
    }
    if(depth > 50) {
      LOG.warning("Probably infinitely nested results, aborting!");
      return;
    }
    for(int i = 0; i < depth; i++) {
      buf.append(' ');
    }
    buf.append(result.getClass().getSimpleName()).append(": ").append(result.getLongName()) //
        .append(" (").append(result.getShortName()).append(")\n");
    if(hier.numChildren(result) > 0) {
      for(It<Result> iter = hier.iterChildren(result); iter.valid(); iter.advance()) {
        recursiveLogResult(buf, hier, iter.get(), depth + 1);
      }
    }
  }