TodoItemNode (@Nullable Object element) { if (element instanceof TodoItemNode) { return (TodoItemNode)element; } else if (element == null) { return null; } else { Object[] children = getTodoTreeStructure().getChildElements(element); if (children.length == 0) { return null; } Object firstChild = children[0]; if (firstChild instanceof TodoItemNode) { return (TodoItemNode)firstChild; } else { return getFirstPointerForElement(firstChild); } } }