Integer (int startNode, int maxWalkSize, boolean isUp) { if (myRedNodes.value(startNode)) return startNode; TreeSetNodeIterator walker = new TreeSetNodeIterator(startNode, isUp); while (walker.notEmpty()) { Integer next = walker.pop(); if (myRedNodes.value(next)) return next; if (maxWalkSize < 0) return null; maxWalkSize--; walker.addAll(getNodes(next, isUp)); } return null; }