Follow a relationship to find connected PIDs.abs.

        :param from_parent: search children from the current pid if True, else
        search for its parents.
        :type from_parent: bool

def _connected_pids(self, from_parent=True):
        """Follow a relationship to find connected PIDs.abs.

        :param from_parent: search children from the current pid if True, else
        search for its parents.
        :type from_parent: bool
        """
        to_pid = aliased(PersistentIdentifier, name='to_pid')
        if from_parent:
            to_relation = PIDRelation.child_id
            from_relation = PIDRelation.parent_id
        else:
            to_relation = PIDRelation.parent_id
            from_relation = PIDRelation.child_id
        query = PIDQuery(
            [to_pid], db.session(), _filtered_pid_class=to_pid
        ).join(
            PIDRelation,
            to_pid.id == to_relation
        )
        # accept both PersistentIdentifier models and fake PIDs with just
        # pid_value, pid_type as they are fetched with the PID fetcher.
        if isinstance(self.pid, PersistentIdentifier):
            query = query.filter(from_relation == self.pid.id)
        else:
            from_pid = aliased(PersistentIdentifier, name='from_pid')
            query = query.join(
                from_pid,
                from_pid.id == from_relation
            ).filter(
                from_pid.pid_value == self.pid.pid_value,
                from_pid.pid_type == self.pid.pid_type,
            )

        return query