while (root.getParent() != null) {
Collection path = new HashSet(); path.add(root); while (root.getParent() != null && !root.isRoot()) { if (path.contains(root.getParent())) { return root; }
    public static IvyNode getRoot(IvyNode parent) {        IvyNode root = parent;        while (root.getParent() != null) {            root = root.getParent();        }        return root;    }