Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final RRNode getParent(RRNode node) {
- Field field = node.getClass().getDeclaredField("parent");
- field.setAccessible(true);
- return field.get(node);
- }
- /**
- * Yields a list of all nodes starting from a given node back to its tree's root node.
- * This assumes that the tree's root node does not have a parent (parent == null).
- */
- public static final java.util.List<RRNode> getBacktrace(RRNode node) {
- java.util.List<RRNode> nodes = new java.util.LinkedList<RRNode>(java.util.Arrays.asList(node));
- RRNode current = node;
- RRNode parent = null;
- while ((parent = getParent(current)) != null) {
- nodes.add(parent);
- current = parent;
- }
- return nodes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement