TodoItemNode (Object element) { if (element instanceof TodoItemNode) { return (TodoItemNode)element; } else { Object[] children = getTodoTreeStructure().getChildElements(element); if (children.length == 0) { return null; } Object firstChild = children[children.length - 1]; if (firstChild instanceof TodoItemNode) { return (TodoItemNode)firstChild; } else { return getLastPointerForElement(firstChild); } } }