Let $\mathscr C$ be a category so that every morphism is 'invertible' only up to equivalence and so that it makes sense to say two morphisms are 'homotopic to each other'. Probably this is called $(2,1)$-category.
(The category in my mind could be such that objects are topological spaces and morphisms are homotopy equivalence maps)
Let $\mathscr D$ be a full subcategory of $\mathscr C$.
Given an object $X\in\mathscr C\setminus \mathscr D$, I attempt to construct a binary relation $\sim_X$ imitating the transitive closure in the set theory. Namely, a pair $(c,d )$ in the set $X$ is related, denoted by $c\sim_X d$, if the following holds:
There exists a sequence $c=c_0,c_1,\dots, c_{n-1},c_n=d$ for an integer $n\ge 0$ so that for every $0\le i\le n-1$ and every pair $(c_i,c_{i+1})$ we may find an object $Y_i\in\mathscr D$, an element $a$ in the set $Y_i$, and two morphisms $f_i^{(0)}, f_i^{(1)}:Y_i\to X$, which are 'homotopic to each other', satisfying $f_i^{(0)}(a)=c_i$ and $f_i^{(1)}(a)=c_{i+1}$.
Question: It seems that this construction gives an equivalence relation on every object set $X$. Is there a categorical generalization of transitive closure?
Since in category setting people often talk about congruence relations rather than equivalence relations. Perhaps this is related to some higher congruence things like here?