/** * Recursively build path to this element (e.g. array(grandparent, parent, this) ) * @return array of parents */ public function get_form_tree() { $tree = array(); if ($this->parent) { $tree = $this->parent->get_form_tree(); } $tree[] = $this; return $tree; }