Here you can find the source of getFirstLeaf(List aList)
public static Object getFirstLeaf(List aList)
//package com.java2s; import java.util.*; public class Main { /**//ww w . ja v a 2s. c om * Returns the first non-list object in the given list hierarchy, recursing if a list is found. */ public static Object getFirstLeaf(List aList) { for (int i = 0, iMax = aList.size(); i < iMax; i++) { Object obj = aList.get(i); if (obj instanceof List) obj = getFirstLeaf((List) obj); if (obj != null) return obj; } return null; } /** * Returns the size of a list (accepts null list). */ public static int size(List aList) { return aList == null ? 0 : aList.size(); } /** * Returns the object at the given index (returns null object for null list or invalid index). */ public static <T> T get(List<T> aList, int anIndex) { return aList == null || anIndex < 0 || anIndex >= aList.size() ? null : aList.get(anIndex); } }