public static View getParent(final View child, final Predicate<View> condition) {
        View result = child;
        while ((condition == null || !condition.test(result)) && (result.getParent() instanceof View)) {
            result = (View) result.getParent();
        }
        return result;
    }
returns the first (direct or indirect) parent of child satisfying the given condition
if child itself satisfies condition, it is returned
if no parent of child does satisfy condition, then root is returned
main/src/main/java/cgeo/geocaching/ui/ViewUtils.java