Using var_dump or print_r will have output in unexpected locations. They are for debugging purposes, and PHP gets the output out immediately.
As far as the rest of it goes, I’m a bit confused, but I think you’re going about this in the wrong way.
In your snippet, you need to get the ultimate parent’s pagetitle. There are two ways you could go about this; you could use a parameter using the UltimateParent snippet as the parameter value:
[!mySnippet? &up=`[[UltimateParent]]`!]
Notice the order of the snippet tags; the outer snippet is uncached and the inner snippet is cached. It has to be this way, otherwise the value of UltimateParent won’t be evaluated first and your snippet will be trying to use the UP snippet tags as the value. This way the inner snippet is evaluated before the outer snippet is, so its return value is now in place. This will give you the $up variable in your snippet to work with.
The other way would be to use
$up = $modx->runSnippet('UltimateParent'); inside your snippet code (or just extract the UltimateParent code into your snippet; it’s not all that much).