CursorTreeAdapter backport + NPE fix