Fixed the caching/retrieving of branches and leaves

Without these changes you will never get any series returned from the
assure_series method and the get_leaves method does not check if a leaf
is actually a leaf…