Pages object != Children object?

Sure,

This template worked well:

edition-item.php

...
<?php $allItems = new Pages() ?>
<?php $allItems->add($p->find('exhibitions')->children()->visible()) ?>
<?php $allItems->add($p->find('events')->children()->visible()) ?>
<?php $allItems->add($p->find('associates-program')->find('research-modules')->children()->visible()) ?>
<?php if($p->find('writer-in-residency')->isVisible()): ?>
	<?php $allItems->add($p->find('writer-in-residency')) ?>
<?php endif ?>
<?php snippet('floating-shapes', ['c' => $allItems]) ?>

But this one did not:

events.php

...
<?php $allChildren = $p->children()->visible() ?>
<?php snippet('floating-shapes', ['c' => $allChildren ]) ?>

This is the snippet called in both templates.

floating-shapes.php

...
<?php $c = $c->sortBy('opening_date', 'asc') ?>
<?php	
$past =  $c->filter(function($p) {
	$now = new DateTime();
	return new DateTime($p->opening_date()) < $now;
})?>
<?php $past = $past->sortBy('opening_date','desc') ?>

<?php $c = $c->without($past)->add($past) /* <--- this caused an error... */ ?> 

<?php foreach($c as $w): ?>
	<?php if($w->uid() == 'writer-in-residency'): /* <--- ...at this line */?> 
    ...

… The whoops was: Call to undefined method Kirby::uid() on the last line.

Either removing the line where $past is added to $c, or changing events.php to this code, fixed the issue:

events.php (fixed)

<?php $allChildren = new Pages() ?>
<?php $allChildren->add($p->children()->visible()) ?>
<?php snippet('floating-shapes', ['c' => $allChildren ]) ?>

As mentioned, var_dumping the collection at events.php gave a different object depending on how it was created, if I use new Pages() I get object(Pages), if I use $var = $p->children()->visible I get object(Children)

Thanks