private static CategoryTreeNode getSubCategory(CategoryTreeNode node, String name) { for (int i = 0; i < node.getChildCount(); i++) { CategoryTreeNode child = (CategoryTreeNode) node.getChildAt(i); if (child.getName().equals(name) || child.isLocalRoot() && LOCAL.equals(name) || child.isRemoteRoot() && REMOTE.equals(name)) return child; } return null; }