memoized hierarchy pos calc