int (MutableTreeNode child, MutableTreeNode parent) { int childCount = parent.getChildCount(); if (childCount == 0) { return 0; } if (childCount == 1) { return NODE_COMPARATOR.compare(child, parent.getChildAt(0)) <= 0 ? 0 : 1; } return findIndexFor(child, parent, 0, childCount - 1); }